Removing trailing slash from ALL URLs in site

jtarr523 picture jtarr523 · Feb 26, 2013 · Viewed 24.3k times · Source

I'm kind of new to the whole .htaccess thing and I've been trying to modify it so that none of my links will have trailing slashes at the end of their respective URLs. My website is filmblurb.org.

The code for the .htaccess where Wordpress begins and ends looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I would appreciate it if someone can lead me in the right direction on how to fix this. Thanks.

Answer

Richard Brown picture Richard Brown · Feb 26, 2013

You can add a RewriteRule to eliminate the trailing slash:

RewriteRule ^(.*)/$ $1 [R=301,L]