Bug 53152 - RewriteRule documentation: Error about per-directory rewrites (RewriteBase)
Summary: RewriteRule documentation: Error about per-directory rewrites (RewriteBase)
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 2.5-HEAD
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: HTTP Server Documentation List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-26 16:37 UTC by Philippe Cloutier
Modified: 2016-08-05 16:21 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Cloutier 2012-04-26 16:37:17 UTC
According to http://httpd.apache.org/docs/trunk/en/mod/mod_rewrite.html#rewriterule

When using the rewrite engine in .htaccess files the per-directory prefix (which always is the same for a specific directory) is automatically removed for the RewriteRule pattern matching and automatically added after any relative (not starting with a slash or protocol name) substitution encounters the end of a rule set. See the RewriteBase directive for more information regarding what prefix will be added back to relative substitions.

First, what this says about re-adding the prefix is unclear. The addition is said to happen when any relative substitution encounters the end of a rule set. But when does a substitution encouter the end of a rule set? The substitution is described as a string, not as a process.

Second, I am not sure what the per-directory prefix would be, but for sure, it is not always the same for a certain directory. For example, suppose /var/www/computers/software/servers/httpd/doc/ is a documentation directory. An alias to that directory is created:
Alias /htdoc /var/www/computers/software/servers/httpd/doc
Therefore, the documentation directory is accessible through either http://example.com/htdoc/ or http://example.com/computers/software/servers/httpd/doc/
Suppose we access index.html. The rewrite rules patterns would normally match
/htdoc/index.html
and
/computers/software/servers/httpd/doc/index.html

But they actually match "index.html" in both cases. This would mean that when accessing index.html via the document root, the per-directory prefix of /var/www/computers/software/servers/httpd/doc would be /computers/software/servers/httpd/doc/. But when accessing via the alias, its prefix would be /htdoc/.

Note typo "substition" (appears once more later in the section).
Comment 1 Rich Bowen 2012-05-04 20:27:24 UTC
This ticket addresses three separate issues.

The typos have been fixed.

Your "First" section, I'm not entirely sure what you are asking. I think that perhaps the term "rule set" should be phased out of use, as there is no such thing. There is a rule, and optionally accompanying RewriteConds. I suppose that's what's meant by a "ruleset"

In your "Second", you describe a situation that shouldn't happen. But, yes, if it does, the "per-directory prefix" would differ between those scenarios, in exactly the manner that you describe, which, I believe, is clear from the documentation. I'm not clear what change you are asking for. Can you suggest alternate phrasing?
Comment 2 Rich Bowen 2012-05-04 20:29:25 UTC
I've updated the phrasing in r1334159 to address these concerns.
Comment 3 Rich Bowen 2012-05-04 20:35:40 UTC
Actually, no. Reverting and reopening. What I changed it to was inaccurate.
Comment 4 Philippe Cloutier 2012-05-05 17:00:28 UTC
Hi Rich,
thanks for the typo fixes.

Regarding the first point, I cannot say how to fix the issue. Ultimately, the reason I'm filing this is that I want to understand the purpose of RewriteBase and how it works. All I can say is that either the documentation should not refer to a substitution encoutering the end of a rule set, or it should be clarified when that happens, by specifying what is considered as a substitution and as a rule set.

Regarding the second point, why should the situation I described not happen? My problem is that what "the per-directory prefix" is is unclear, and even misleading as it currently stands.
Comment 5 Rich Bowen 2016-08-05 16:21:03 UTC
Phrasing clarified in r1755361 (trunk) and r1755363 (2.4)