Redirection to Enforce Trailing Slash on URLs

If you need to enforce a trailing slash at the end of your URLs you can use the following helper plugin. Note that as long as your canonical URLs are correctly set, Google will index the desired URL even without this fix.

📥  Download (.zip): WP Rocket | Enforce Trailing Slash on URLs
Developers: You can find the code for this plugin on GitHub.

These are the rules that the above helper plugin adds to the .htaccess file:

# Force trailing slash
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|xml|txt|js|php|scss|webp|mp3|avi|wav|mp4|mov)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.