我需要重写以下内容:
http://www.mystuff.com/drinks/category/beer?page=1
到
https://www.mystuff.com/food-drink/beer/ale
无论我尝试将URI重写到新地址,但它都会保留附加的查询字符串。我需要失去这个。我已经尝试了很多选项,似乎没有任何工作,任何人都可以提供一些建议。 我以为这会做到,但没有:
RewriteCond %{QUERY_STRING} (.*)(?:^|&)page=(?:[^&]*)((?:&|$).*)
RewriteCond %1%2 (^|&)([^&].*|$)
RewriteRule ^(/drinks/category/beer)$ https://www.mystuff.com/food-drink/beer/ale [R=301, L]
有人可以帮忙吗?
答案 0 :(得分:1)
您需要添加一个空查询字符串以在重写时截断它。在重写结尾添加一个?
:
RewriteCond %{QUERY_STRING} (.*)(?:^|&)page=(?:[^&]*)((?:&|$).*)
RewriteCond %1%2 (^|&)([^&].*|$)
RewriteRule ^(/drinks/category/beer)$ https://www.mystuff.com/food-drink/beer/ale? [R=301, L]