Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect displays subdomain 1

Status
Not open for further replies.
Jul 28, 2005
358
FR
Hi,

I have an addon domain on my hosting package (cpanel admin system). Using this, I also have some redirects (mainly htm redirect to php files).

When they redirect, it always seems to load the subdomain url that the addon domain is set up as. EG. a
RedirectMatch 301 (.*)\.htm$ $1.php
on the page redirects to example.maindomain.com/page.php instead of example.com/page.php (where example.com is the addon domain and maindomain.com is the main hosting domain).

Anyone got any ideas on how to stop this happening so the correct domain name is shown in the address bar of the browser?

Thanks,

Richard
 
Hi

I heard somehow similar problems with some hosts, where the subdomains was not real subdomains, just made to look like. In those cases there was no solution to correct the behaviour.

Feherke.
 
When I created the addon domain with my host, it created a subdomain (it shows up as a subdimaon in my hosting info), so I presume it is a real subdomain.

Just need an idea on how to sort a redirect out from the subdomain to the actual domain (but actually keeping the rest of the url which is a dynamic php one with values in the url string).

Richard
 
definitly a real subdomain as far as I can tell. Unfortunately I don't have access to the httpd.conf to double check, but I'm pretty sure it is.
 
Hi

Ok, then I suggest an ugly but comfortable solution ( should work, although I did not tried it ).

Set the files with .htm extension to be parsed for PHP codes :
Code:
AddType application/x-httpd-php .htm
The [tt]AddType[/tt] directive can be used in .htaccess files too. If is not disallowed in httpd.conf.

Feherke.
 
I thought of that too, but unfortunately the client explicitly stated they want the redirect so I don't have any choice!!

If only people would listen eh!!

Thanks for the help, much appreciated.

Richard
 
Doesn't seem to make any difference, but I've just noticed that it doesn't always happen. It seems to only do it once there has been an initial redirect already.

EG, I have some language flags, the first time you click one, it's all fine, but then if you do it again the link is now the subdomain rather than the proper url.

Very strange!!

Richard
 
I suppose what I really want is to create a rule that redirects addondomain.maindomain.com to addondomain.com but with the rest of the url still intact.

I'm certainly not an expert on this at all, so any help is gratefully recieved.

Richard
 
Hi

Sorry, I did not found the links to .htm files. In fact I found some, but all was external links. I followed some of them, but I did not seen such problem as you described : the domain remained unchanged.

Feherke.
 
Reason they sem OK now are because I've just remembered I took off the .htaccess (sorry!!). The links aren't actually externala as such, the other domain is pointed to a folder using DNS - looks external but in effect not.

Anyway, you can see a similar problem if you use the language flags at the top of the page. Try turning it into French then back to English and you should see what I mean. I would like to have a rule that resolves back to the proper domain name.

Thanks,

Richard
 
Hi

Ah, now I see it. But those links are sent like that from the server. So I would put some [tt]phpinfo();[/tt] or [tt]print_r($_SERVER);[/tt] commands into the index.php to see which pathes change.

Anyway, is really strange. The other links are pointing to the right domain...

Feherke.
 
Right, been reading up on it and beginning to get my head round redirects.

Th eproblem I am having is if I want to tell a directory to redirect to a domain name.

I thought that if I put this in an .htaccess file placed at /folder/folder2
Code:
Redirect 301 /folder/folder2 [URL unfurl="true"]http://www.newdomain.com/[/URL]

That any file in this folder would redirect and show the page as (it's worth pointing out here that newdomain.com is setup using url-hiding to forward to this directory, the problem has been that it displays the original domain name - this is related to the language flags I mentioned earlier).

With the redirect setup, it brings me an error saying that the redirect would never complete although /folder/folder2/index.php is in exactly the same place on the server as
Anyone know what would cause this (it also puts aload of /////// between the domain name and the index.php)

Thanks,

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top