
covener at apache
Nov 4, 2009, 3:48 PM
Post #1 of 1
(53 views)
Permalink
|
|
svn commit: r832914 - in /httpd/httpd/trunk/docs/manual/mod: mod_rewrite.html.en mod_rewrite.xml
|
|
Author: covener Date: Wed Nov 4 23:48:52 2009 New Revision: 832914 URL: http://svn.apache.org/viewvc?rev=832914&view=rev Log: add an early note about the Pattern in a rewriterule behaving counterintuitively in per-directory context. (lots of mysterious no-op rulesets due to ^/ in htaccess) Tweak QSA text. Modified: httpd/httpd/trunk/docs/manual/mod/mod_rewrite.html.en httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml Modified: httpd/httpd/trunk/docs/manual/mod/mod_rewrite.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_rewrite.html.en?rev=832914&r1=832913&r2=832914&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/mod/mod_rewrite.html.en (original) +++ httpd/httpd/trunk/docs/manual/mod/mod_rewrite.html.en Wed Nov 4 23:48:52 2009 @@ -947,11 +947,23 @@ <div class="note"><h3>What is matched?</h3> <p>The <em>Pattern</em> will initially be matched against the part of the - URL after the hostname and port, and before the query string. If you wish - to match against the hostname, port, or query string, use a + URL after the hostname and port, and before the query string.</p> + + <p>When the RewriteRule appears in per-directory (htaccess) context, the + <em>Pattern</em> is matched against what remains of the URL after removing + the prefix that lead Apache to the current rules (see the + <code class="directive"><a href="#rewritebase">RewriteBase</a></code>). The removed prefix + always ends with a slash, meaning the matching occurs against a string which + never has a leading slash. A <em>Pattern</em> with <code>^/</code> never + matches in per-directory context.</p> + + <p>If you wish to match against the hostname, port, or query string, use a <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or - <code>%{QUERY_STRING}</code> variables respectively.</p> + <code>%{QUERY_STRING}</code> variables respectively. If you wish to + match against the full URL-path in a per-directory (htaccess) RewriteRule, + use the <code>%{REQUEST_URI}</code> variable.</p> + </div> <p>For some hints on <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular @@ -1325,10 +1337,11 @@ <dt>'<code>qsappend|QSA</code>' (query string append)</dt><dd> - This flag forces the rewrite engine to append a query - string part of the substitution string to the existing string, + This flag forces the rewrite engine to append the query + string part of the substitution string to the existing query string, instead of replacing it. Use this when you want to add more - data to the query string via a rewrite rule.</dd> + data to the query string via a rewrite rule. This rule has no net effect + unless your substitution explicitly provides a new query string.</dd> <dt>'<code>redirect|R</code> [=<em>code</em>]' (force <a id="redirect" name="redirect">redirect</a>)</dt><dd> Modified: httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml?rev=832914&r1=832913&r2=832914&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml (original) +++ httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml Wed Nov 4 23:48:52 2009 @@ -959,11 +959,23 @@ <note><title>What is matched?</title> <p>The <em>Pattern</em> will initially be matched against the part of the - URL after the hostname and port, and before the query string. If you wish - to match against the hostname, port, or query string, use a + URL after the hostname and port, and before the query string.</p> + + <p>When the RewriteRule appears in per-directory (htaccess) context, the + <em>Pattern</em> is matched against what remains of the URL after removing + the prefix that lead Apache to the current rules (see the + <directive module="mod_rewrite">RewriteBase</directive>). The removed prefix + always ends with a slash, meaning the matching occurs against a string which + never has a leading slash. A <em>Pattern</em> with <code>^/</code> never + matches in per-directory context.</p> + + <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> + <code>%{QUERY_STRING}</code> variables respectively. If you wish to + match against the full URL-path in a per-directory (htaccess) RewriteRule, + use the <code>%{REQUEST_URI}</code> variable.</p> + </note> <p>For some hints on <glossary ref="regex">regular @@ -1342,10 +1354,11 @@ <dt>'<code>qsappend|QSA</code>' (query string append)</dt><dd> - This flag forces the rewrite engine to append a query - string part of the substitution string to the existing string, + This flag forces the rewrite engine to append the query + string part of the substitution string to the existing query string, instead of replacing it. Use this when you want to add more - data to the query string via a rewrite rule.</dd> + data to the query string via a rewrite rule. This rule has no net effect + unless your substitution explicitly provides a new query string.</dd> <dt>'<code>redirect|R</code> [=<em>code</em>]' (force <a id="redirect"
|