Hello.
I use mod_rewrite/.htaccess for pretty URLs. I forward all the requests to my index.php, like this:
RewriteRule ^/?([a-zA-Z0-9/-]+)/?$ /index.php [NC,L]
The index.php then handles the requests.
I'm also using this condition/rule to eliminate trailing slashes (or rather rewrite them to the URL without a trailing slash, with a 301 redirect; I'm doing this to avoid duplicate content and because I like no trailing slashes better):
RewriteCond %{HTTP_HOST} !^\.localhost$ [NC] RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
This works well, except that I now get an infinite loop when trying to access a (real) directory (the rewrite rule removes the trailing slash, the server adds it again, ...).
I solved this by setting the DirectorySlash
directive to Off
:
DirectorySlash Off
I don't know how good this solution is, I don't feel too confident about it tbh.
Anyway, what I'd like to do is completely ignore "real" files and directories, since I don't need them and I only use pretty URLs with "virtual" files/directories anyway. This would allow me to avoid the DirectorySlash
workaround/hack too.
Is this possible?
Thanks!