Kevin Smith
Kevin Smith

Reputation: 111

How to remove an element/parameter from URL by .htaccess

I would remove color_new=any-value-could-be-here anywhere in URL via .htaccess So how to do it?

Upvotes: 1

Views: 68

Answers (1)

anubhava
anubhava

Reputation: 785246

You can use this rule to remove a query parameter from any where in query string:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.+?&)?color_new=[^&]*(?:&(.*))?$
RewriteRule ^ %{REQUEST_URI}?%1%2 [R=302,L]

Keep this rule above other rules.

Upvotes: 1

Related Questions