How to remove url parameters in php using .htaccess?

by giovanny.lueilwitz , in category: Third Party Scripts , 9 months ago

How to remove url parameters in php using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , 8 months ago

@giovanny.lueilwitz 

To remove URL parameters in PHP using .htaccess, you can use the following code in your .htaccess file:

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


This code will check if there are any query parameters in the URL and remove them by redirecting to the same URL without the parameters. The [R=301,L] flag will also perform a 301 redirect, which is a permanent redirect.


Save the .htaccess file and place it in the root directory of your website. This will remove any parameters from the URL when accessed.

Related Threads:

How to remove php extension form url with .htaccess?
How to remove part of url using .htaccess?
How to get url parameters using shopify liquid?
How to remove .cgi from url with .htaccess?
How to remove get parameter from url with .htaccess?
How to remove .php .html via .htaccess?