htaccess重定向冲突/不工作

时间:2015-01-12 15:25:00

标签: regex apache .htaccess mod-rewrite redirect

我有一个需要重定向到新页面的二维码。由于某种原因,重定向被覆盖(最终在cmdgroup.com/community而不是appropritate页面)

RewriteCond %{HTTP_HOST} ^(.*)?companies/Inova-Solutions-Inc/Network-Clocks-by-Inova-Solutions/53e4f5e048e43c1d5cef656d [NC]
RewriteRule ^(.*)$ http://www.cmdgroup.com/companies/1142841/inova-solutions-inc/ [R=301,L] 

RewriteCond %{HTTP_HOST} ^(.*)?community.cmdgroup.com [NC,OR]
RewriteCond %{HTTP_HOST} ^(.*)?community.reedconstructiondata.com [NC]
RewriteRule ^(.*)$ http://www.cmdgroup.com/community/ [R=301,L] 

1 个答案:

答案 0 :(得分:1)

这是因为您的第一个RewriteCond %{HTTP_HOST}错误,因为您只使用%{HTTP_HOST}变量匹配域名。将该规则更改为:

RewriteRule companies/Inova-Solutions-Inc/Network-Clocks-by-Inova-Solutions/53e4f5e048e43c1d5cef656d$ http://www.cmdgroup.com/companies/1142841/inova-solutions-inc/ [R=301,L] 

RewriteCond %{HTTP_HOST} community\.(cmdgroup|reedconstructiondata)\.com$ [NC]
RewriteRule ^ http://www.cmdgroup.com/community/ [R=301,L]