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.
The issue is not caused by .htaccess, but rather by a combination of wordpress permalinks and .htaccess.
Login to your site and navigate to the permalinks, then if you aren't using the custom structure option, switch to it and make sure to not have a trailing slash at the end:
Then add this to your .htaccess file, above the
That is better than using rewrite since it's a redirect and not a rewrite.
If that still doesn't work then I recommend you install the yoast seo plugin and there is a setting in it to do this.
This works for me; removing all trailing slashes from all routes while emphasizing that REQUEST_URI starts with a slash (at least in .htaccess files):
Just don't use
%{REQUEST_URI} (.*)/$
. Because in the root directory REQUEST_URI equals /, the leading slash, and it would be misinterpreted as a trailing slash.SOURCE: https://stackoverflow.com/a/27264788/2732184
You can add a RewriteRule to eliminate the trailing slash: