Fully restrict access to sub-directories with .htaccess

.htaccessapache-2.2

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.

Best Answer

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

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

Just a hunch, haven't tested it.