1

我一直在试图弄清楚如何编写新的重写规则,但我挣扎得很厉害。我们正在从 domain.com 中删除全球 (WW) 站点,并希望将所有旧链接转发到国家/地区选择器。任何帮助,将不胜感激。先感谢您。

# if any user goes to this URL
www.domain.com/products/folder1/folder2/index?sku=123&var2=abc&isocountrycode=ww

# forward them to this URL
www.domain.com/choose/country_selection?ref_url=/products/folder1/folder2/index.cfm?sku=123&var2=abc

# my attempt that does not work
RewriteCond %{QUERY_STRING}     ^(.*)isocountrycode=ww(.*)$    [NC]
RewriteRule ^(.+)$      /choose/country_selection.cfm?ref_url=$1?%1%2 [L,R=302]

我一直在使用这个网站来测试我的代码http://martinmelin.se/rewrite-rule-tester/

4

1 回答 1

0

回答了我自己的问题。Helicontech APE 需要第二个?用反斜杠转义...

RewriteCond %{QUERY_STRING} ^(.+&)?isocountrycode=ww&(.+)?$ [NC]
RewriteRule ^(.+)$ /choose/country_selection.cfm?ref_url=/$1\?%1%2? [NC,R=301,L]
RewriteCond %{QUERY_STRING} ^((.+)&)?isocountrycode=ww$ [NC] 
RewriteRule ^(.+)$ /choose/country_selection.cfm?ref_url=/$1\?%2? [NC,R=301,L]
于 2013-08-26T18:35:40.297 回答