htaccess: exluce some domain in RewriteCond
this is my .htaccess code so if the user type just domain.com will be redirected to www.domain.com
开发者_如何学PythonRewriteBase /
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.
精彩评论