Samul
Samul

Reputation: 2019

RewriteEngine inside multiple htaccess files

I have 2 .htaccess files, onde inside /aaa and another inside /aaa/bbb.

When in both files I use:

RewriteEngine On

The rules of the first htaccess (/aaa) are completely ignored and only the rules of the second (/aaa/bbb) are interpreted. What is even stranger is that if I have many rules inside the first htaccess (/aaa) and NONE inside (/aaa/bbb) BUT I keep the linke above inside the htaccess of /aaa/bbb all the rules inside /aaa/.htaccess are still ignored.

How can I have multiple files with RewriteEngine On and have apache to respect all of them in order of the tree directory (low directory first and high last).

Upvotes: 2

Views: 225

Answers (1)

anubhava
anubhava

Reputation: 785256

How can I have multiple files with RewriteEngine On and have apache to respect all of them in order of the tree directory (low directory first and high last).

In your aaa/bbb/.htaccess you should be using RewriteOptions as:

RewriteOptions Inherit

Note that it will have this behavior:

Rules inherited from the parent scope are applied after rules specified in the child scope

EDIT:

If you use InheritBefore the order will be inverted (which is what OP needed at first place), i.e. the parent rules will be executed first and the child ones later.

See official documentation for mode details

Upvotes: 0

Related Questions