Forum Moderators: phranque

Message Too Old, No Replies

<Directory> and <Files> precedence

Blocking a dir while allowing some files?

         

pdest

2:44 pm on Jan 31, 2007 (gmt 0)

10+ Year Member



Hello,

I'm trying to do something that I thought was going to be simple... but no :)
I want to block all the access to my site, and only allow visitors to see index.html. The reason for this is that I have a service check for httpd and I would like a 200 back instead of a 403.

Here's what I've added:

<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
# Allow from all <- Commented out, so the default "deny" will apply
# Allow access for everyone to index.html
<Files index.html>
Order allow,deny
Allow from all
</Files>
</Directory>

I've tried some variations, including <Files ~ "index.html">, <Files /var/www/html/index.html>, etc but with no luck. I understand that I can nest these directives and that <Files> should override <Directory>.
I've tried AllowOverride All, with no effect (I know, I was desperate!).

Maybe I'm overlooking something, any clues?

Thanks!

Pablo

jdMorgan

3:14 pm on Jan 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The 'and' and 'or' terms used in the description of the "Order" directive in mod_access [httpd.apache.org] are critical to understanding how Allows and Denys are prioritized. I'd suggest trying this:


<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order Deny,Allow
Deny from all
# Allow access for everyone to index.html in /html or in any subdirectory of /html
<Files index.html>
Allow from all
</Files>
</Directory>

Jim