How to remove specific query_string parameter in .htaccess?

by darrion.kuhn , in category: Third Party Scripts , 9 days ago

How to remove specific query_string parameter in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lily , 9 days ago

@darrion.kuhn 

To remove a specific query string parameter in .htaccess, you can use the following code:


For example, if you want to remove the "param" query string parameter from URLs:

1
2
3
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)param= [NC]
RewriteRule ^(.*)$ /$1? [R=301,L]


This code checks if the "param" query string parameter is present in the URL and removes it with a 301 redirect. Change "param" to the specific query string parameter you want to remove.