Semantics of "RewriteOptions inherit" in htaccess files needs improvement

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

 



I'd like to propose two improvements to the semantics of
"RewriteOptions inherit" appearing in an htaccess file.

#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.

You can see an example of this in the attached tar file, designed to be
untarred as a "htaccess-rewrite-inherit-test" directory in the
DocumentRoot.  A request for
/htaccess-rewrite-inherit-test/subdir/foo.html gives a 404 error due to
the application of an inherited rule that was anchored with ^ in the
intent that it should apply only
to /htaccess-rewrite-inherit-test/foo.html .  If the subdir/.htaccess
file is deleted, this request is handled as intended.

I propose storing the RewriteBase with each rule so that a parental rule
behaves the same way when inherited as when the child has no mod_rewrite
configuration.

#2. When a directory is requested without a trailing slash, mod_rewrite
skips running that directory's rules to avoid unpredictable behavior
resulting from the inability to strip the RewriteBase (see bug 20195).
However, if the directory said "RewriteOptions inherit", I think
inherited rules should still run, as they would if the directory had no
mod_rewrite configuration.  This could be implemented by removing the
check from the beginning of hook_fixup and instead skipping each
individual rule if the request does not begin with its RewriteBase.

Comments?  I can try to implement this, but I'm new to the Apache code
base, so I don't know how far I'll get.

-- 
Matt

Attachment: htaccess-rewrite-inherit-test.tar.gz
Description: application/compressed-tar

---------------------------------------------------------------------
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