Forum Moderators: phranque

Message Too Old, No Replies

.htaccess inheritance - How does it work?

I find this confusing. Can anyone help?

         

dream3r quazar

1:56 am on Jul 11, 2006 (gmt 0)

10+ Year Member



Dear friends,

I have a parent directory which contains a .htaccess file that allows me access to a file:

<Files index.php>
Order Allow,Deny
Allow from all
</Files>

Yet in a subdirectory of it, I have another .htaccess file which should block all files in it from my browser (not using "Files" or "FilesMatch" here):

SetEnvIf User-Agent ^Mozilla block
Order Allow,Deny
Allow from all
Deny from env=block

Suprisingly, the file, index.php in the subdirectory is still accessible to my browser! Isn't the .htaccess file in the subdirectory supposed to overwrite the config of the .htaccess file in its parent directory?

When does it overwrite and when does it not? I also notice that if I use "FilesMatch" in the parent directory .htaccess file, I have have to use "FilesMatch" in the subdirectory in order to overwrite the config.
Is there such a thing? How does all this work?

Or is there an easier way to prevent inheritance of .htaccess config from its parent directories? Is there a command to type in .htaccess to indicate that we want to start afresh from "Allow All" and do not inherit from any of its parent directories?

Can anyone enlightenment me? Thank you!

jdMorgan

3:02 pm on Jul 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



.htaccess-file handling is described in these Apache documents:

.htaccess files [httpd.apache.org]
Using .htaccess Files with Apache [apache-server.com]

Jim

[edited by: jdMorgan at 3:02 pm (utc) on July 11, 2006]