Forum Moderators: phranque

Message Too Old, No Replies

rewriting sub-domian url

Using htaccess to rewrite subdomain url.

         

Chris_m

4:53 am on Mar 15, 2004 (gmt 0)

10+ Year Member



I'm trying to use

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?sub.domain.com$ [NC]
RewriteRule ^(.*)$ [domain.us...] [L,R=permanent]

to rewrite "sub.domain.com" to domain.us.

It works but only if someone goes to sub.domain.com, sub.domain.com/dir/. If they go to sub.domain.com/dir/filename.htm or sub.domain.com/dir they get redirected to the main index. And if there isn't a trailing slash, it results in a 500 error. I'm so lost trying to fix this. Any suggestions?

closed

3:24 am on Mar 17, 2004 (gmt 0)

10+ Year Member



Maybe you have an .htaccess in sub.domain.com/dir?

Whenever you get an error, you should try looking at your error log, because it may give more insight into the problem.

jdMorgan

12:23 am on Mar 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We're seeing a lot of these recently.

I'm going to take a guess and say that some popular hosting company has set up their httpd.conf with UseCanonicalName set to "on" and an incorrect canonical name for each their hosted users. The canonical name is either missing a trailing slash when it should have one, or it has a trailing slash and should not.

The same thing can probably happen due to similar errors setting up name-based mass virtual hosting.

If anyone has a test server and can test this, it might help out a lot of people.

JIm

Chris_m

12:40 am on Mar 18, 2004 (gmt 0)

10+ Year Member



I'm hosted with bloghosts. Should I shoot them an email and ask?

@ Closed

Yes, the htaccess is in the subdomain. There doesn't seem to be problems with anything else but overwriting or rewriting the domain name but I can pull all the htaccess out of the subdomain and put it on the main domain and see if that makes a difference.