How to remove specific query_string parameter in .htaccess?

by darrion.kuhn , in category: Third Party Scripts , 8 months ago

How to remove specific query_string parameter in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lily , 8 months 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.

Related Threads:

How to remove get parameter from url with .htaccess?
How to add a parameter to a url using .htaccess without breaking in wordpress?
How to redirect a parameter to a subfolder with .htaccess?
How to redirect a parameter to a subfolder with .htaccess?
How to redirect subdirectory to url parameter in .htaccess?
How to redirect to a specific url in htaccess?