DirectorySlash
has an inherent information disclosure security concern when you turn it off. That means if you turn it off (and you do need to), you have to take care of the trailing slash yourself. So something like this:
DirectorySlash Off
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ /$1/ [L]
Note that this is essentially doing the same thing DirectorySlash
does, but instead of redirecting the browser, you're internally rewriting the URI to add the trailing slash. This means it's there as far as the webserver is concerned but the browser doesn't see it.
You can then do the checks for index.php
:
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ (.*)/index\.php
RewriteRule ^(.*?)/?index.php$ /$1 [L,R=301]