Is there a way with mod_rewrite to sanitize an URL of this type:
https://www.example.com/blabla/?¶m1=1¶m2=2
to
https://www.example.com/blabla/?param1=1¶m2=2
Thank you
CodePudding user response:
RewriteCond %{QUERY_STRING} ^&(.*)
RewriteRule ^(.*)$ /$1?%1 [R=301,L]
That should basically do it. The RewriteCond matches on any query string that starts with &
, and simply captures the rest.
And then you simply insert the back reference to that "rest" into the substitution URL, using %1
.
Edit: Pattern changed to (.*)
to capture all URL paths; back reference $1
inserted into substitution URL.