Question
How does Apache apply .htaccess directives, and in what order are they read?
Answer
Apache reads .htaccess files starting from the top-level directory and then works to apply rules as read to any subdirectories from where the rule was found.
Example:
/$USER/public_html/.htaccess
The .htaccess located in the path specified above will also affect any of the subdirectories located within "public_html".
/$USER/public_html/
\__uploads
\__store
\__blog
However, .htaccess rules can override previous directives found in previous directories as they are applied in the order that they are read.
This means that if you have a rule that you wish to not apply to a subdirectory you will have to override the behaviour with a new .htaccess in the subdirectory you wish to change the behaviour.
For more details, please refer to Apache's official documentation.
Comments
0 comments
Article is closed for comments.