简体   繁体   中英

htaccess to remove specific query string from url

I have the URL

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

The i value changes 1 to 3. I want to transform that URL into this:

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

Whenever the query string parameter i is found in the URL, the i has to be removed from the URL.

You can use this rule to remove parameter i from the query string from any position:

RewriteEngine On

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM