Multiple levels of .htaccess files with RewriteRule, only deepest level processed

.htaccessapache-2.2mod-rewrite

I have .htaccess files at multiple levels of a directory heirarchy, each with RewriteRules in them. However, when arequest is made for a file in a subdirectory, only the rules in the most deeply nested .htaccess file (up to the level of the requested file) are ever processed. Even having only a single line with "RewriteEngine On" is a subdirectory is enough to "disable" all rewrites defined in higher directories. This happens both for apache and litespeed httpd.

I had expected (and can't find any information otherwise) that all the RewriteRules would be combined into a single ruleset (presumably with deeper levels being processed last). However this doesn't seem to be happening.

Quite confused 🙂 What am I not understanding?

Thanks,
Mike.

Best Answer

Have you set RewriteOptions Inherit in each .htaccess?

In per-directory context this means that conditions and rules of the parent directory's .htaccess configuration are inherited. Rules inherited from the parent scope are applied after rules specified in the child scope.

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteoptions