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?

1 Answer 1

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]
Sign up to request clarification or add additional context in comments.

1 Comment

This is perfect! Thank you very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.