Forum Moderators: phranque
# Excluding the "customers" directory URL-path,
RewriteCond $1 !^customers/
# allow and retain optional parm(s) before hop= name/value, but none after
RewriteCond %{QUERY_STRING} ^(([^&]*(&[^&]*)*)&)?hop=[^&]*$ [OR]
# require and retain parm(s) before and accepts optional parm(s) after hop= name/value
RewriteCond %{QUERY_STRING} ^(([^&]*(&[^&]*)*)&)hop=[^&]*((&[^&]*)*)$
RewriteRule ^(.*)$ http://www.example.com/$1?%2%4 [R=301,L]
It is unclear why you found it necessary to use %{THE_REQUEST} in your rewritecond.
1- How could I make it that it blocks for example ?hop and ?blingUse the regex subpattern (hop|bling)
On my site I also use ?tags, and that should definitely NOT be blocked.
2- Is it possible to block every ?* but ?tags.
3- If I want to block this rule for more than one directory, could I do it with:
RewriteCond $1 !^customers/|login/|example
# Redirect to remove all query string parameters except "tag=" name/value
# pairs from all requested URLs, excluding several directories
RewriteCond $1 !^(customers|login|example)/
RewriteCond %{QUERY_STRING} !^(tag=[^&]*)?$
RewriteCond %{QUERY_STRING} ^([^&]*&)*(tag=[^&]*)
RewriteRule ^(.*)$ http://www.example.com/$1?%2 [R=301,L]