htaccess从url中删除特定的查询字符串

时间:2017-09-03 10:50:32

标签: regex .htaccess

我有网址

http://example.com/index.php?err=true&i=1

i值更改为1到3.我想将该网址转换为:

http://example.com/index.php?err=true 

每当在网址中找到查询字符串参数i时,必须从网址中删除i

1 个答案:

答案 0 :(得分:0)

您可以使用此规则从任意位置从查询字符串中删除参数i

RewriteEngine On

RewriteCond %{THE_REQUEST} \?(.*&)?i=[^&]*&?(\S*)\sHTTP [NC]
RewriteRule ^ %{REQUEST_URI}?%1%2 [R=308,NE,L]