Mod_rewrite delete parameter in 301 Redirect

Posted by Jack on Server Fault See other posts from Server Fault or by Jack
Published on 2011-01-03T00:43:46Z Indexed on 2011/01/03 0:55 UTC
Read the original article Hit count: 210

Hi,

How would I go about rewriting:

http://www.example.com/foo.html?order=desc&limit=all&something=else

to

http://www.example.com/foo.html?order=desc&something=else

I want to remove all instances on limit=all regardless of how many other parameters in the url.

I have tried:

RewriteCond %{QUERY_STRING} ^(.*&)&limit=all(&.*)?$ [NC]
RewriteRule ^foo\.html$ /foo\.html\?%1%2 [R=301,L]

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about .htaccess