Search code examples
apache.htaccessdirectory-structuresubdirectory

htaccess files with "deny from all" does it deny subdirectories as well?


If I have a directory structure like this:

- index.php
- public
    - img
    - css
- application
    - controllers
        - user
        - admin
    - models
    - views
    .htaccess

I'm using the index.php as my front controller so all MVC classes and files are included and don't require directory access.

In the .htaccess I have Deny from all inside it and it sits in the application directory. Does that effectively deny direct file access and directory listing to all the sub-directories under the application directory as well? Or do I need to put the .htaccess file inside each sub-directory as well?

Many thanks


Solution

  • Yes - .htaccess works for the whole tree inside the directory. To override it's rules you have to add the given rule in a subdir and then the new .htaccess will work for the whole tree inside that subdir.