With .htaccess, how can I block access to any sub-directories (and its contents) when they are accessed directly (using the browser's address bar for example)?

I'm on a shared host, so I do not have access to the main httpd.conf file. I realize I can simply put a file with "Deny from all" inside the sub-directories, but I'd like to do it from my single root .htaccess file.

migrated from stackoverflow.com Oct 11 '11 at 11:22

This question came from our site for professional and enthusiast programmers.

<Directory /var/www/*>
     Order Deny,Allow
     Deny from All

<Directory /var/www/>
     Order Allow,Deny
     Allow from All

Just a hunch, haven't tested it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy