RewriteEngine on
RewriteBase /
#redirect to domain2 if on domain1.com and path doesn't start with /blog
RewriteCond %{HTTP_HOST} !=domain1.com
RewriteCond $0 !^blog
RewriteRule .* http://domain2.com/$0
RewriteEngine on
RewriteBase /
#redirect to domain2 if on domain1.com and path doesn't start with /blog
RewriteCond %{HTTP_HOST} !=domain1.com
RewriteCond $0 !^blog
RewriteRule .* http://domain2.com/$0
Add a RewriteCond around HTTP_HOST above your RewriteRule doing the redirect. You can even write it for the one you don't want to redirect for, and negate it.
For example:
RewriteCond %{HTTP_HOST} !=Domain1.com
Note that you can have multiple RewriteConds, but each grouping (one or more) will only apply to the very next RewriteRule*.
发布评论
评论(2)
在
位于执行重定向的RewriteCond
>HTTP_HOSTRewriteRule
之上。您甚至可以为您不想重定向的人编写它,然后否定它。例如:
请注意,您可以有多个
RewriteCond
,但每个分组(一个或多个)仅适用于下一个RewriteRule
*。Add a
RewriteCond
aroundHTTP_HOST
above yourRewriteRule
doing the redirect. You can even write it for the one you don't want to redirect for, and negate it.For example:
Note that you can have multiple
RewriteCond
s, but each grouping (one or more) will only apply to the very nextRewriteRule
*.