Apache gotcha: RewriteOptions inherit

The Apache 2.2 documentation on RewriteOptions inherit indicates only that “parent” rules, maps, and conditions are inherited, but not what inheritance means in this context. Since RewriteRule directives are processed in the order in which they appear in the configuration, it matters where the inherited directives are placed when the complete configuration is interpreted.

As it happens, “parent” rules are places after “child” rules — e.g., server-level rules are inherited by a virtual host after the rules defined in the virtual host container.  This behavior is consistent with how Apache scopes directives.  But you do have to be careful about conflicting rules, particularly rules that match any URL, for example:

RewriteRule ^/.* - [G]

If such a “catch-all” rule appears in your virtual host configuration, then no RewriteRule or RewriteCond directives from your server context will actually be effective in the virtual host context.  This misconfiguration has bitten me a few times, and can be confusing if you’ve never encountered it before.