htaccess的:exluce在一定的RewriteCond域 [英] htaccess: exluce some domain in RewriteCond
问题描述
这是我的.htaccess code
因此如果用户只输入domain.com将被重定向到www.domain.com
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]
我现在的问题是,我有一个新的域名指向同一个域路径
因此,即使新的域名重定向透明,以domain.com ...
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?
谢谢!
推荐答案
您可以尝试使改写通用的,因此,所有不与 WWW
被重定向开始请求,但正确的/请求的域。
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]
或者,您可以检查,而不是因为如果域名以 domain.com
:
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]
希望这有助于。
这篇关于htaccess的:exluce在一定的RewriteCond域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!