Re: Semantics of "RewriteOptions inherit" in htaccess files needs improvement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2009-02-01 at 23:19 +0100, Bob Ionescu wrote:
> 2009/1/31 Matt McCutchen <matt@xxxxxxxxxxxxxxxxx>:
> > #1. Currently, "RewriteOptions inherit" works as if the parent's rules
> > were copied and pasted into the child (after any other rules).  This
> > means that requests in the child directory are tested against the
> > parent's rules after stripping the /child's/ RewriteBase.  Thus, the
> > parent's rules have a different effect when inherited by "RewriteOptions
> > inherit" compared to when the child has no mod_rewrite configuration at
> > all, in which case they are tested after stripping the /parent's/
> > RewriteBase.  I found this behavior surprising.
> 
> Mhmmm; actually, that's exactly what I'm using in environments where I
> don't have access to the main server configuration. :-)

Just because you're relying on the current behavior doesn't make it
right.

> E.g. domain1 points to /var/www, domain2 to /var/www/sub and
> /var/www/sub/.htaccess inherits (i.e. 1:1 copy) /var/www/.htaccess. A
> regEx of ^foo$ in /var/www/sub/.htaccess would match against a
> filename /var/www/foo and against /var/www/sub/foo in
> /var/www/sub/.htaccess caused by inheriting, which is intended (the
> per-dir prefix is striped prior matching, of course). The URL-path
> (which doesn't matter in per-dir context for matching) would be in
> both cases /foo while the domain is different.
> 
> Two different setups - two different intentions about overriding the
> parent configuration and the inheritage of the rules.

Yes, but I believe my intention is more reasonable.  The purpose of
htaccess files is to provide localized control.  Interpreting rules
defined by a directory with respect to *that directory*, rather than the
nearest ancestor of the request that happens to have any rewrite
configuration, seems more in keeping with that spirit.  I'd argue that
if you want to affect /var/www/foo and also /var/www/sub/foo, that
should really be two separate rules (unless you want to affect any file
named "foo", in which case you could just omit the ^ anchor).

If your /var/www/sub/.htaccess included /var/www/.htaccess via an
explicit "Include" directive (assuming Apache supported them in htaccess
files), I would agree.  But I believe the intent of htaccess inheritance
(which is hard-wired to be from the parent) is to apply settings to
subtrees, not to serve as a generic configuration templating mechanism.

As I work on my own Web site, I'm beginning to need some form of
configuration templating.  My plan is to generate the htaccess files
with m4, not to abuse htaccess inheritance.

-- 
Matt


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux