2013-08-23 42 views
1

我一直在试图弄清楚如何编写一个新的重写规则,但我正在苦苦挣扎。我们正在从domain.com移除全球(WW)网站,并且希望将任何旧链接转发到国家/地区选择器。任何帮助,将不胜感激。先谢谢你。查询字符串中的多个变量的Apache RewriteRule

# 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/

回答

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]