I have the following .htaccess
rule but I would only like it to run it if a file exists without the removed trailing slash:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
I use LiteSpeed.
Also, what is the difference between the following 2 file checks? And is there any reason that they would both need to be used at the same time for 1 rule? (I currently have a few rules with both).
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
^(.*)/$
to map to files in the first place, so there may be something else you need to do here (rather than simply slap on a condition that checks whether the request maps to a file). Have you checked the Apache Docs (mod_rewrite introduction andRewriteCond
reference)?