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:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(.*&)&limit=all(&.*)?$ [NC]
RewriteRule ^foo\.html$ /foo\.html\?%1%2 [R=301,L]
You have
^(.*&)&limit=all(&.*)?$
which expects two ampersands in a row before limit.Since you're certain that you'll always have parameters on both sides of the limit=all, change it to
^(.*&)limit=all&(.*)$
After a bit more playing around I was able to achieve this with the following:
Thanks to Chris S for the suggestion to remove the ampersands