htacces, remove trailing slash

Written by
Date: 2020-03-30 22:15:00 00:00

In order to avoid duplicate content like this:

http://domain/page and http://domain/page/

It is a good idea to remove the trailing slash from the URI, if you are using Apache, that can be done with the .htaccess file.

Just add these lines and it will work.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]

The first line may already exist in your .htacess file, if it does not, add it.