How to remove trailing slashes in URLs using .htaccess

.htaccess for automatically removing (and redirecting) URLs with trailing slashes

# remove trailing slash from URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

Leave a Reply