我正在尝试完成一些重定向,如下所示:
#Basic Rule Set
RewriteRule ^/path$ http://newhost.com/Page?pagename=form1000 [R=301]
RewriteRule ^/path/index.html$ http://newhost.com/Page?pagename=form1000 [R=301]
哪个工作正常。
但是,在源和目标中使用查询字符串进行重定向会将我返回到上述目标 url。例如,
# Advanced Rule Set
RewriteRule ^/path/index.html?var=foo$ http://newhost.com/Page?pagename=form1000?id=hello [R=301]
RewriteRule ^/path/index.html?var=bar$ http://newhost.com/Page?pagename=form1000?id=byebye [R=301]
RewriteRule ^/path/index.html?var=xyz$ http://newhost.com/Page?pagename=form1000?id=world [R=301]
全部重定向到http://newhost.com/Page?pagename=form1000
. 我已经在上述三个规则之前尝试了 a RewriteCond %{QUERY_STRING} ^var=(.*)$ [NC]
and RewriteCond %{REQUEST_URI} ^/path/index.html [NC]
,但我仍然被重定向到http://newhost.com/Page?pagename=form1000
. 我交换了 Basic 和 Advanced 规则集的顺序,并全部重定向到http://newhost.com/Page?pagename=form1000
.
关于如何让这些规则集发挥作用的任何想法?CentOS 6.x,阿帕奇 2.2。