<p><a id="patterns" name="patterns"><em>Pattern</em></a> is
a perl compatible <a id="regexp" name="regexp">regular
- expression</a>.
- the (%-decoded) <a href="directive-dict.html#Syntax">URL-path</a>
- of the request, or, in per-directory context (see below), the URL
- path relative to that per-directory context. Subsequent patterns
- are matched against the output of the last matching RewriteRule.</p>
+ expression</a>. What this pattern is compared against varies depending
+ on where the <directive>RewriteRule</directive> directive is defined.
<note><title><a id="what_is_matched" name="what_is_matched">What is matched?</a></title>
<p>In <directive module="core">VirtualHost</directive> context,
The <em>Pattern</em> will initially be matched against the part of the
URL after the hostname and port, and before the query string (e.g. "/app1/index.html").
- This is the (%-decoded) <a href="directive-dict.html#Syntax">URL-path</a></p>
+ This is the (%-decoded) <a href="directive-dict.html#Syntax">URL-path</a>.</p>
<p>In <directive module="core">Directory</directive> and htaccess context,
- the <em>Pattern</em> will initially be matched against the
- <em>filesystem</em> path, after removing the leading directory path where the
- <directive>RewriteRule</directive> was defined. In this context,
- some example strings matched against are "index.html and "app1/index.html
- (but never anything beginning with a slash). </p>
+ the <em>Pattern</em> is matched against the trailing portion of the currently
+ mapped filesystem path with the rules own directory path removed from the beginning
+ (up to and including a trailing slash). Directives such as <directive
+ >DocumentRoot</directive> and <directive>Alias</directive>, or even the
+ result of previous <directive>RewriteRule</directive> substitutions, determine
+ the currently mapped filesystem path. The net result of this per-directory
+ prefix stripping is that rules in this context only match against the portion
+ of the currently mapped path "below" where they are defined.</p>
<p>If you wish to match against the hostname, port, or query string, use a
<directive module="mod_rewrite">RewriteCond</directive> with the
a user's directory, then you cannot use the rewrite engine. This
restriction is required for security reasons.</li>
-<li>When using the rewrite engine in <code>.htaccess</code> files the
-per-directory prefix (which always is the same for a specific
-directory) is automatically <em>removed</em> for the RewriteRule pattern matching
-and automatically <em>added</em> after any relative (not starting with a
-slash or protocol name) substitution encounters the end of a rule set.
-See the <directive module="mod_rewrite">RewriteBase</directive>
+<li>See the <directive module="mod_rewrite">RewriteBase</directive>
directive for more information regarding what prefix will be added back to
relative substitutions.</li>