1

I am looking to redirect all pages on a website by removing any that contain ?cont= within the URL using RedirectMatch 301.

For example; /my-page.html?cont=uk would 301 redirect to /my-page.html

however this needs to also work for URL's with multiple query strings in; /my-page.html?cont=uk&size=100 would 301 redirect to /my-page.html?size=100

If needed I can supply all of the variations of what cont= can be, there are around 25. Is this possible?

1 Answer 1

1

You can use this rule as your very first rule in site root .htaccess to remove cont= parameter from any position:

RewriteEngine On

RewriteCond %{THE_REQUEST} \?(.*&)?cont=[^&]*&?(\S*)\sHTTP [NC]
RewriteRule ^ %{REQUEST_URI}?%1%2 [R=301,NE,L]

# rest of your rules go here
Sign up to request clarification or add additional context in comments.

Comments

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.