I’m trying to remove the trailing slash from my sub-directory folders in Apache 1.3.42 however the command DirectorySlash Off is not supported in my version of Apache when I
You need to add a couple of other rules besides removing the trailing slash. With DirectorySlash Off
, the redirect from no slash to trailing slash stops, but if you access any directory, it will print the contents of the directory instead of displaying the index file.
This means you must internally add a trailing slash to directories. So change these lines:
#removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]
To:
DirectorySlash Off
#removing trailing slash
RewriteCond %{THE_REQUEST_FILENAME} \ /(.*)/(\ |$|\?)
RewriteRule ^(.*)/$ $1 [R=301,L]
# internally add the slash back
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ /$1/ [L]