I have a webserver and I need to create a 403 forbidden for all folders ( include sub folders) that do not have any index file , I know I can do it with .htaccess , but as far as I know It only used for main folder , not sub folders . how can I block accessing website folders that do not have index file ?
thanks
Even with DirectoryIndex on
this rule should work for you:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{DOCUMENT_ROOT}/$1/index.php !-f
RewriteRule ^(.+?)/?$ - [F]
I found this link useful for disabling DirectoryIndex:
http://www.ducea.com/2006/06/26/apache-tips-tricks-disable-directory-indexes/