0

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]
Jack
  • 25

2 Answers2

0

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&(.*)$

DerfK
  • 19,826
0

After a bit more playing around I was able to achieve this with the following:

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

Thanks to Chris S for the suggestion to remove the ampersands

Jack
  • 25