Force trailing slash

It’s often a good idea to either force trailing slashes or remove them, as it can lead to duplicate content. The htaccess code below will force trailing slash by performing a 301 permanent redirect.

RewriteEngine on
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

You can test the effect by browsing to http://your-domain.com/some-directory and verify that you are redirected to http://your-domain.com/some-directory/.