2017-06-13 159 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