As my web project sometimes throws 404s if trailing slashes are missing I always want my server to add trailing slashes to the URLs. Therefore I have used the following pattern in .htaccess:
# ################################## #
# Redirect URLs which are not files to their trailing slash equivalent #
# ################################## #
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]
It looked fine but then I realized that links like
were converting to
Which is obviously undesirable and makes the website break. How do I have to rewrite this rule such that any requests for files (.php, .jpg, .html, etc.) are for sure not included?