<note><title><a id="what_is_matched" name="what_is_matched">What is matched?</a></title>
-<ul>
- <li><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></li>
-
- <li><p>In <glossary ref="perdirectory">per-directory context</glossary>
- (<directive module="core">Directory</directive> and .htaccess),
- the <em>Pattern</em> is matched against only a partial path, for example a request
- of "/app1/index.html" may result in comparison against "app1/index.html"
- or "index.html" depending on the directory-path for which the
- <directive>RewriteRule</directive> applies.</p>
-
- <p>The directory-path to which the rule applies is stripped from the currently mapped
- filesystem path before comparison (up to and including a trailing slash).
- The net result of this <glossary ref="perdirectory">per-directory</glossary> prefix stripping is that rules in
- this context only match against the portion of the currently mapped filesystem path
- "below" the directory-path to which the rule applies.</p>
-
- <p>Directives such as <directive module="core"
- >DocumentRoot</directive> and <directive module="mod_alias">Alias</directive>, or even the
- result of previous <directive>RewriteRule</directive> substitutions, determine
- the currently mapped filesystem path.
- </p>
- </li>
-
- <li><p>If you wish to match against the hostname, port, or query string, use a
- <directive module="mod_rewrite">RewriteCond</directive> with the
- <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
- <code>%{QUERY_STRING}</code> variables respectively.</p></li>
-</ul>
+<p>
+The <em>Pattern</em> is matched against the %-decoded URL-path
+(in server context) or the directory-relative path (in
+<glossary ref="perdirectory">per-directory context</glossary>).
+See <a href="../rewrite/intro.html#rewriterule">RewriteRule
+Basics</a> for details on what the pattern is matched against
+in each context.
+</p>
</note>
<note><title><glossary ref="perdirectory">Per-directory</glossary> Rewrites</title>
</ol>
<p>The <var>Pattern</var> is a <a href="#regex">regular expression</a>.
-It is initially (for the first rewrite rule or until a substitution occurs)
-matched against the URL-path of the incoming request (the part after the
-hostname but before any question mark indicating the beginning of a query
-string) or, in per-directory context, against the request's path relative
-to the directory for which the rule is defined. Once a substitution has
-occurred, the rules that follow are matched against the substituted
-value.
+In server or virtualhost context, it is matched against the
+%-decoded <a href="../directive-dict.html#Syntax">URL-path</a>
+of the incoming request — the part after the hostname and port,
+and not including the query string (e.g., <code>/app/index.html</code>).
+In <glossary ref="perdirectory">per-directory context</glossary>,
+the pattern is matched against the request's path relative to the
+directory for which the rule is defined (with the directory prefix
+stripped — see <a href="htaccess.html#path-stripping">Per-directory
+Rewrites</a> for details).
</p>
+<p>Once a substitution has occurred, any rules that follow are
+matched against the substituted value.</p>
+
+<p>The <var>Pattern</var> is matched only against the URL-path
+— not the hostname, port, or query string. To match against
+those, use a
+<directive module="mod_rewrite">RewriteCond</directive> with the
+<code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
+<code>%{QUERY_STRING}</code> variables respectively.</p>
+
<p class="figure">
<img src="../images/syntax_rewriterule.png"
alt="Syntax of the RewriteRule directive" /><br />