2017-06-13 142 views
0

我想任何格式301多個網址參數重定向

mydomain.com/?main_page=products_new 
mydomain.com/?main_page=products_new&page=2 
mydomain.com/?main_page=products_new&disp_order=2 

重定向到該

mydomain.com/new-products 

我有這樣的工作只有第一個參數。我怎樣才能忽略其餘的並且匹配任何含有?main_page-products_new

RewriteCond %{QUERY_STRING} ^main_page=products_new [NC] 
RewriteRule ^(.*) /new-products? [L,R=301] 

回答

0

Apache支持RedirectMatch

RedirectMatch 301 ^main_page=products_new.*$ /new-products?$1

+0

這是行不通的。我使用RedirectMatch爲其他網站沒有問題。 – user78955

+0

如果您將^ main ...更改爲^ .main,該怎麼辦? –

+0

仍然不起作用。 – user78955