This is my .htaccess file:
# NO LISTING OF INDEXES Options -Indexes <IfModule mod_rewrite.c> RewriteEngine On # NIX THE www BECAUSE IT IS NO LONGER 1996 AND YOU'RE COOLER THAN THAT RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)/$ http://%1/$1 [R=301,L] # NIX TRAILING SLASHES BECAUSE SEO IS A VENGEFUL GOD AND WHATNOT RewriteRule ^(.*)/$ $1 [R=301,L] # SEND ALL NON-FILE REQUESTS TO index.php FOR FIGURING OUT RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # ERROR DOCS ErrorDocument 400 /error/400 ErrorDocument 401 /error/401 ErrorDocument 403 /error/403 ErrorDocument 404 /error/404 ErrorDocument 500 /error/500
If I try to access the folder ( /images/ or /images or some other real folder in my site structure), it gets into the redirect cycle.
I tried adding RewriteCond %{REQUEST_FILENAME} !-d before the trailing slash rule and βfixedβ the redirection if it now forcibly terminates the slash in the corresponding folders, but also passed the folder name to my script, as if it were baked by requesting a URI for my CMS to understand.
I think now I could fix this on the CMS side by checking if the URI is a folder that someone is trying to list illegally, but ideally there would be an elegant .htaccess solution to redirect folder list calls to one of those banned pages, which I declare so well there. Does anyone know about this?
source share