2013-08-23 39 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]