How delete "?" from url with .htaccess?


by vinnie , in category: SEO , 7 months ago

How delete "?" from url with .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by percy_bauch , 7 months ago


To remove the question mark "?" from a URL using .htaccess, you can use the following code:

RewriteEngine On
RewriteCond %{QUERY_STRING} .
RewriteRule ^ %{REQUEST_URI}? [L,R=301]

This code will redirect any URL that contains a question mark to the same URL without the question mark. The [L,R=301] flag at the end of the RewriteRule line indicates a permanent redirect, and the trailing ? in the substitution string removes the query string.