Friday, October 31, 2014

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



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.


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


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...