this is my .htaccess code so if the user type just domain.com will be redirected to www.domain.com
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
my problem now is that i have a new domain pointing to the same domain path so even the new domain is redirected "transparently" to domain.com...
how can i exclude some domain name from that rule?
thanks!
You could try making the rewrite generic, so all requests that are not starting with www
are redirected, but on the correct/requested domain.
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [L,R=301]
Or, you can check instead for if the domain starts with domain.com
:
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com [L,R=301]
Hopefully this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With