I have a URL that looks something like this:
https://www.example.com/about-us?stage=Stage&utm_source=abc&utm_medium=xyz
I want to just remove the stage=Stage part.
I tried the below code:
RewriteCond %{QUERY_STRING} ^stage=Stage$
RewriteRule (.*) $Stage? [R=permanent]
but it only seems to work if the URL is:
https://www.example.com/about-us?stage=Stage
without the rest of the parameters.
How can I make the other parameters pass over apart from the stage=Stage parameter?
You can use this rule at the top of your .htaccess:
RewriteCond %{QUERY_STRING} ^(.*&)?stage=Stage(?:&(.*))?$ [NC]
RewriteRule ^ %{REQUEST_URI}?%1%2 [L,R=301,NE]