How to remove trailing slash on URL parameter for SEO friendliness

In .htaccess

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.+)/$
RewriteRule ^ %{REQUEST_URI}?%1 [R=301,L,NE]

Now all https://sitename.com/url?hello=world/ URLs will become https://sitename.com/url?hello=world

If changing the .htaccess file doesn’t seem to make any difference, make sure that in Apache general config that AllowOverride All is set otherwise .htaccess files will not be interpreted.

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top