Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.