Forum Moderators: phranque

Message Too Old, No Replies

Addon domain affected by rewrite rules.

         

sren

8:44 am on Aug 16, 2006 (gmt 0)

10+ Year Member



I've no experience with .htaccess and rewrite rules.
I have a shared hosting account with a main site up and running, and a htaccess with a 301 redirection like this:

RewriteCond %{HTTP_HOST}!^www\.mysite\.com [NC]
RewriteRule ^(.*) [mysite.com...] [L,R=301].

To redirect mysite.com to www.mysite.com.

Now I've a new domain (addon in the same account), and these rewrite rules are sending addon.com to mysite.com/addon.

Anyone has a hint on how to keep addon.com from being redirected without removing these mod rules?

Thanks a lot.

jdMorgan

1:25 pm on Aug 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is likely that the first line of your code says "If the domain is NOT www.mysite.com" and so the RewriteRule will be invoked for <anything>.mysite.com except for www.mysite.com.

You can use an alternate form that will redirect ONLY mysite.com to www.mysite.com:


RewriteCond %{HTTP_HOST} ^mysite\.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]

If you are using this code without understanding how it works, I would caution you that this is a dangerous thing to do. A single mistake can take your server down -- Or worse, cause a seemingly-intermittent problem that is almost impossible to find without understanding the code.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim