我想从
重定向www.site1.info?index.php?id=243&L=&tx_kesearch_pi1%5Bsword%5D=YOU
www.site1.info/search/search/?L=&tx_kesearch_pi1[sword]=YOU
要
www.site2.org?index.php?id=243&L=&tx_kesearch_pi1%5Bsword%5D=YOU
www.site2.org/search/search/?L=&tx_kesearch_pi1[sword]=YOU
注意
我只想重新定位,如果......
www.site1.info?index.php?id=243
www.site1.info/search/search/
...而不是重定向正在进行的查询(将其移植到site2.org
我尝试失败了:
RewriteCond %{HTTP_HOST} ^(www\.)site1\.info/index.php?id=243$ [NC]
RewriteRule ^ http://www.site2.org/index.php?id=243%{REQUEST_URI} [NE,R=301,L]
答案 0 :(得分:1)
您无法与REQUEST_URI
中的QUERY_STRING
或RewriteCond %{HTTP_HOST}
匹配。
您可以使用此代码:
RewriteCond %{HTTP_HOST} ^(www\.)site1\.info$ [NC]
RewriteCond %{QUERY_STRING} (?:^|&)id=243(?:&|$) [NC]
RewriteRule ^index\.php$ http://www.site2.org/index.php?id=243%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)site1\.info$ [NC]
RewriteRule ^search/search/?$ http://www.site2.org/index.php?id=243%{REQUEST_URI} [NE,R=301,L]