5

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?

Sybille Peters
  • 2,832
  • 1
  • 27
  • 49
GiarcTNA
  • 499
  • 2
  • 17

1 Answers1

3

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]
anubhava
  • 761,203
  • 64
  • 569
  • 643