How does htaccess recursion work?

I work in a situation where I have a main website located in ~/www . I have several subdomains hosted in ~/www/__subdomains . Basically webroot, I have a .htaccess file that does a bit of correspondence. In my two subdomains, I have similar .htaccess , and these subdomains respond correctly.

In 2 other recently created subdomains, I have .htaccess files that are empty, stored for the AddHandler directive. I find that the root existence / content .htaccess file affects these 2 subdomains. They throw 500 errors. Once I rename this, broken subdomains work.

This of course tears apart other sites, so I can't just take it off, but it breaks my understanding of how .htaccess recursion works. I thought that as long as there is a .htaccess file in a subdirectory, those in the ancestral directories will never be executed.

It’s clear that I’m wrong about this, so I hope someone can educate me and help me fix it.

Thanks.

+6
source share
1 answer

.htaccess files are applied from the current directory up, stopping in the main configuration. Any rules and directives that are in the current .htaccess directory will supersede any other rules found in evaluating .htaccess in the future.

However, the problem, as you discovered, is that rules that are not explicitly overridden apply from other files. You can refer to the Apache.htaccess Tutorial for further explanation, in particular, How directives are applied .

Hope this helps.

+8
source

Source: https://habr.com/ru/post/887403/


All Articles