Remove trailing slash (redirect to remove trailing slash) in .htaccess
October 26, 2018
If you want to redirect from http://example.com/test/ to http://example.com/test (i.e. remove the slash at the end of URLs) then you can use the following .htaccess code:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]
This will 301 redirect to the non trailing slash version of the page
Don't forget that you will probably need to enable the rewrite engine for these rules to work. Click the button below to find out how to do this.