Trailing Slash Error

saz99

New Member
#1
I want to add a trailing slash after all my URLs

This is the code that I have on my .htaccess

Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.domain.com/$1/ [L,R=301]

But it is not working. I also restarted the lightspeed webserver after editing the .htaccess

How do I add a trailing slash after all my URLs?
 
#2
Give this a try, Saz. Once you are satisfied, the 307s (temporary) can be changed to 301s (permanent): I don't put it in .htaccess, though. I added it to the top of my Rewrites in the Rewrite tab in OLS.

Apache config:
# Remove trailing slash from non-filepath urls
RewriteCond %{REQUEST_URI} /(.+)/$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\/$ $1 [R=307,L]

# Include trailing slash on directory
RewriteCond %{REQUEST_URI} !(.+)/$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ $1/ [R=307,L]
 
Last edited:
Top