]> granicus.if.org Git - apache/blobdiff - docs/manual/mod/mod_rewrite.html.en
documentation rebuild
[apache] / docs / manual / mod / mod_rewrite.html.en
index c59ca4b5a77de237366fa7619a12855892504871..2d2c62122b3133ba807413c286fa393a702c706a 100644 (file)
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
+<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
+<!--
         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
               This file is generated from xml source: DO NOT EDIT
         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@@ -17,7 +19,7 @@
 <div id="page-header">
 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
 <p class="apache">Apache HTTP Server Version 2.5</p>
-<img alt="" src="../images/feather.gif" /></div>
+<img alt="" src="../images/feather.png" /></div>
 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
 <div id="path">
 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
@@ -66,7 +68,9 @@ URLs on the fly</td></tr>
 <li><img alt="" src="../images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
 </ul>
-<ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
+<h3>Bugfix checklist</h3><ul class="seealso"><li><a href="https://www.apache.org/dist/httpd/CHANGES_2.4">httpd changelog</a></li><li><a href="https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__open__&amp;list_id=144532&amp;product=Apache%20httpd-2&amp;query_format=specific&amp;order=changeddate%20DESC%2Cpriority%2Cbug_severity&amp;component=mod_rewrite">Known issues</a></li><li><a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2&amp;component=mod_rewrite">Report a bug</a></li></ul><h3>See also</h3>
+<ul class="seealso">
+<li><a href="#comments_section">Comments</a></li></ul></div>
 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="logging" id="logging">Logging</a></h2>
@@ -115,38 +119,39 @@ URLs on the fly</td></tr>
 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
 </table>
       <p>The <code class="directive">RewriteBase</code> directive specifies the
-      URL prefix to be used for per-directory (htaccess) 
-      <code class="directive">RewriteRule</code> directives that substitute a relative
-      path.</p>
+      URL prefix to be used for per-directory (htaccess)
+      <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives that
+      substitute a relative path.</p>
       <p> This directive is <em>required</em> when you use a relative path
-      in a substitution in per-directory (htaccess) context unless either
+      in a substitution in per-directory (htaccess) context unless any 
       of the following conditions are true:</p>
       <ul>
-          <li> The original request, and the substitution, are underneath the 
+          <li> The original request, and the substitution, are underneath the
                <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>
-               (as opposed to reachable by other means, such as 
+               (as opposed to reachable by other means, such as
                <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>).</li>
           <li> The <em>filesystem</em> path to the directory containing the
-               <code class="directive">RewriteRule</code>, suffixed by the relative 
-               substitution is also valid as a URL path on the server 
+               <code class="directive"><a href="#rewriterule">RewriteRule</a></code>,
+               suffixed by the relative
+               substitution is also valid as a URL path on the server
                (this is rare).</li>
-          <li> In Apache HTTP Server 2.4.11 and later, this directive may be 
-                omitted when the request is mapped via 
+          <li> In Apache HTTP Server 2.4.16 and later, this directive may be
+                omitted when the request is mapped via
                 <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>
                 or <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code>.</li>
       </ul>
 
 <p> In the example below, <code class="directive">RewriteBase</code> is necessary
     to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
-    since the resource was not relative to the document root.  This 
+    since the resource was not relative to the document root.  This
     misconfiguration would normally cause the server to look for an "opt"
     directory under the document root.</p>
-<pre class="prettyprint lang-config">DocumentRoot /var/www/example.com
+<pre class="prettyprint lang-config">DocumentRoot "/var/www/example.com"
 AliasMatch "^/myapp" "/opt/myapp-1.2.3"
 &lt;Directory "/opt/myapp-1.2.3"&gt;
     RewriteEngine On
-    RewriteBase /myapp/
-    RewriteRule ^index\.html$  welcome.html 
+    RewriteBase "/myapp/"
+    RewriteRule "^index\.html$"  "welcome.html"
 &lt;/Directory&gt;</pre>
 
 
@@ -158,7 +163,7 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
 </td></tr>
 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
-      <em>TestString</em> <em>CondPattern</em></code></td></tr>
+      <em>TestString</em> <em>CondPattern</em> [<em>flags</em>]</code></td></tr>
 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
@@ -298,7 +303,6 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
                 respectively.</p>
 
                 <p>Those that are special to mod_rewrite include those below.</p>
-        <div class="note">
                 <dl>
                   <dt><code>API_VERSION</code></dt>
 
@@ -343,9 +347,9 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
                   been determined by the server at the time
                   <code>REQUEST_FILENAME</code> is referenced. Otherwise,
                   such as when used in virtual host context, the same
-                  value as <code>REQUEST_URI</code>.  Depending on the value of 
+                  value as <code>REQUEST_URI</code>.  Depending on the value of
                   <code class="directive"><a href="../mod/core.html#acceptpathinfo">AcceptPathInfo</a></code>, the
-                  server may have only used some leading components of the 
+                  server may have only used some leading components of the
                   <code>REQUEST_URI</code> to map the request to a file.
                   </dd>
 
@@ -359,7 +363,7 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
 
                   <dd>The path component of the requested URI,
                   such as "/index.html".  This notably excludes the
-                  query string which is available as as its own variable
+                  query string which is available as its own variable
                   named <code>QUERY_STRING</code>.</dd>
 
                   <dt><code>THE_REQUEST</code></dt>
@@ -372,7 +376,6 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
                   (decoded), unlike most other variables below.</dd>
 
                 </dl>
-</div>
         </li>
       </ul>
 
@@ -420,7 +423,9 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
         <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
         the empty string if it is not.  Example:
         <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
-        <code>128</code>.</li>
+        <code>128</code>. These variables are available even without
+        setting the <code>StdEnvVars</code> option of the
+        <code class="directive"><a href="../mod/mod_ssl.html#ssloptions">SSLOptions</a></code> directive.</li>
 
         <li>
         <code>%{HTTP:header}</code>, where <em>header</em> can be
@@ -439,7 +444,7 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
         so that certain conditions might not be evaluated at all.</p></li>
 
         <li>
-        <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a> 
+        <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
         can be used for look-aheads which perform
         an internal (URL-based) sub-request to determine the final
         value of <em>variable</em>. This can be used to access
@@ -485,136 +490,159 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
         <li>
           You can perform lexicographical string comparisons:
 
-          <ul>
-            <li>'<strong>&lt;CondPattern</strong>' (lexicographically
-            precedes)<br />
+          <dl>
+            <dt><strong>&lt;CondPattern</strong></dt>
+            <dd>Lexicographically precedes<br />
             Treats the <em>CondPattern</em> as a plain string and
             compares it lexicographically to <em>TestString</em>. True if
             <em>TestString</em> lexicographically precedes
-            <em>CondPattern</em>.</li>
+            <em>CondPattern</em>.</dd>
 
-            <li>'<strong>&gt;CondPattern</strong>' (lexicographically
-            follows)<br />
+            <dt><strong>&gt;CondPattern</strong></dt>
+            <dd>Lexicographically follows<br />
             Treats the <em>CondPattern</em> as a plain string and
             compares it lexicographically to <em>TestString</em>. True if
             <em>TestString</em> lexicographically follows
-            <em>CondPattern</em>.</li>
+            <em>CondPattern</em>.</dd>
 
-            <li>'<strong>=CondPattern</strong>' (lexicographically
-            equal)<br />
+            <dt><strong>=CondPattern</strong></dt>
+            <dd>Lexicographically equal<br />
             Treats the <em>CondPattern</em> as a plain string and
             compares it lexicographically to <em>TestString</em>. True if
             <em>TestString</em> is lexicographically equal to
             <em>CondPattern</em> (the two strings are exactly
             equal, character for character). If <em>CondPattern</em>
             is <code>""</code> (two quotation marks) this
-            compares <em>TestString</em> to the empty string.</li>
+            compares <em>TestString</em> to the empty string.</dd>
 
-            <li>'<strong>&lt;=CondPattern</strong>' (lexicographically
-            less than or equal to)<br />
+            <dt><strong>&lt;=CondPattern</strong></dt>
+            <dd>Lexicographically less than or equal to<br />
             Treats the <em>CondPattern</em> as a plain string and
             compares it lexicographically to <em>TestString</em>. True
             if <em>TestString</em> lexicographically precedes
             <em>CondPattern</em>, or is equal to <em>CondPattern</em>
-            (the two strings are equal, character for character).</li>
+            (the two strings are equal, character for character).</dd>
 
-            <li>'<strong>&gt;=CondPattern</strong>' (lexicographically
-            greater than or equal to)<br />
+            <dt><strong>&gt;=CondPattern</strong></dt>
+            <dd>Lexicographically greater than or equal to<br />
             Treats the <em>CondPattern</em> as a plain string and
             compares it lexicographically to <em>TestString</em>. True
             if <em>TestString</em> lexicographically follows
             <em>CondPattern</em>, or is equal to <em>CondPattern</em>
-            (the two strings are equal, character for character).</li>
-        </ul></li>
+            (the two strings are equal, character for character).</dd>
+        </dl>
+        </li>
 
         <li>
           You can perform integer comparisons:
-          <ul>
+          <dl>
 
-            <li>'<strong>-eq</strong>' (is numerically
-            <strong>eq</strong>ual to)<br />
+            <dt><strong>-eq</strong></dt>
+            <dd>Is numerically <strong>eq</strong>ual to<br />
             The <em>TestString</em> is treated as an integer, and is
             numerically compared to the <em>CondPattern</em>. True if
-            the two are numerically equal.</li>
+            the two are numerically equal.</dd>
 
-            <li>'<strong>-ge</strong>' (is numerically
-            <strong>g</strong>reater than or <strong>e</strong>qual to)<br />
+            <dt><strong>-ge</strong></dt>
+            <dd>Is numerically <strong>g</strong>reater than or <strong>e</strong>qual to<br />
             The <em>TestString</em> is treated as an integer, and is
             numerically compared to the <em>CondPattern</em>. True if
             the <em>TestString</em> is numerically greater than or equal
-            to the <em>CondPattern</em>.</li>
+            to the <em>CondPattern</em>.</dd>
 
-             <li>'<strong>-gt</strong>' (is numerically
-            <strong>g</strong>reater <strong>t</strong>han)<br />
+            <dt><strong>-gt</strong></dt>
+            <dd>Is numerically <strong>g</strong>reater <strong>t</strong>han<br />
             The <em>TestString</em> is treated as an integer, and is
             numerically compared to the <em>CondPattern</em>. True if
             the <em>TestString</em> is numerically greater than
-            the <em>CondPattern</em>.</li>
+            the <em>CondPattern</em>.</dd>
 
-            <li>'<strong>-le</strong>' (is numerically
-            <strong>l</strong>ess than or <strong>e</strong>qual to)<br />
+            <dt><strong>-le</strong></dt>
+            <dd>Is numerically <strong>l</strong>ess than or <strong>e</strong>qual to<br />
             The <em>TestString</em> is treated as an integer, and is
             numerically compared to the <em>CondPattern</em>. True if
             the <em>TestString</em> is numerically less than or equal
             to the <em>CondPattern</em>. Avoid confusion with the
             <strong>-l</strong> by using the <strong>-L</strong> or
-            <strong>-h</strong> variant.</li>
+            <strong>-h</strong> variant.</dd>
 
-             <li>'<strong>-lt</strong>' (is numerically
-            <strong>l</strong>ess <strong>t</strong>han)<br />
+            <dt><strong>-lt</strong></dt>
+            <dd>Is numerically <strong>l</strong>ess <strong>t</strong>han<br />
             The <em>TestString</em> is treated as an integer, and is
             numerically compared to the <em>CondPattern</em>. True if
             the <em>TestString</em> is numerically less than
             the <em>CondPattern</em>. Avoid confusion with the
             <strong>-l</strong> by using the <strong>-L</strong> or
-            <strong>-h</strong> variant.</li>
+            <strong>-h</strong> variant.</dd>
+
+            <dt><strong>-ne</strong></dt>
+            <dd>Is numerically <strong>n</strong>ot <strong>e</strong>qual to<br />
+            The <em>TestString</em> is treated as an integer, and is
+            numerically compared to the <em>CondPattern</em>. True if
+            the two are numerically different. This is equivalent to
+            <code>!-eq</code>.</dd>
 
-           </ul>
+           </dl>
         </li>
 
         <li>You can perform various file attribute tests:
-          <ul>
-            <li>'<strong>-d</strong>' (is
-            <strong>d</strong>irectory)<br />
+
+
+          <dl>
+
+          <dt><strong>-d</strong></dt>
+
+          <dd>Is <strong>d</strong>irectory.<br />
              Treats the <em>TestString</em> as a pathname and tests
-            whether or not it exists, and is a directory.</li>
+            whether or not it exists, and is a directory.
+          </dd>
+
+          <dt><strong>-f</strong></dt>
+
+          <dd>Is regular <strong>f</strong>ile.<br />
 
-            <li>'<strong>-f</strong>' (is regular
-            <strong>f</strong>ile)<br />
              Treats the <em>TestString</em> as a pathname and tests
-            whether or not it exists, and is a regular file.</li>
+            whether or not it exists, and is a regular file.
+        </dd>
 
-            <li>'<strong>-F</strong>' (is existing file, via
-            subrequest)<br />
+           <dt><strong>-F</strong></dt>
+
+           <dd>Is existing file, via subrequest.<br />
             Checks whether or not <em>TestString</em> is a valid file,
             accessible via all the server's currently-configured
             access controls for that path. This uses an internal
             subrequest to do the check, so use it with care -
-            it can impact your server's performance!</li>
+            it can impact your server's performance!
+           </dd>
+
+            <dt><strong>-h</strong></dt>
+            <dd>Is symbolic link, bash convention.<br />
+            See <strong>-l</strong>.
+            </dd>
 
-            <li>'<strong>-H</strong>' (is symbolic link, bash convention)<br />
-            See <strong>-l</strong>.</li>
+            <dt><strong>-l</strong></dt>
 
-            <li>'<strong>-l</strong>' (is symbolic
-            <strong>l</strong>ink)<br />
+            <dd>Is symbolic <strong>l</strong>ink.<br />
             Treats the <em>TestString</em> as a pathname and tests
             whether or not it exists, and is a symbolic link. May also
             use the bash convention of <strong>-L</strong> or
             <strong>-h</strong> if there's a possibility of confusion
             such as when using the <strong>-lt</strong> or
-            <strong>-le</strong> tests.</li>
+            <strong>-le</strong> tests.
+            </dd>
 
-            <li>'<strong>-L</strong>' (is symbolic link, bash convention)<br />
-            See <strong>-l</strong>.</li>
+            <dt><strong>-L</strong></dt>
+            <dd>Is symbolic link, bash convention.<br />
+            See <strong>-l</strong>.</dd>
 
-            <li>'<strong>-s</strong>' (is regular file, with
-            <strong>s</strong>ize)<br />
+            <dt><strong>-s</strong></dt>
+            <dd>Is regular file, with <strong>s</strong>ize.<br />
             Treats the <em>TestString</em> as a pathname and tests
             whether or not it exists, and is a regular file with size greater
-            than zero.</li>
+            than zero.</dd>
 
-            <li><p>'<strong>-U</strong>' (is existing URL, via
-            subrequest)<br />
+            <dt><strong>-U</strong></dt>
+            <dd><p>Is existing URL, via subrequest.<br />
             Checks whether or not <em>TestString</em> is a valid URL,
             accessible via all the server's currently-configured
             access controls for that path. This uses an internal
@@ -622,22 +650,28 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
             it can impact your server's performance!</p>
             <p> This flag <em>only</em> returns information about things
             like access control, authentication, and authorization.  This flag
-            <em>does not</em> return information about the status code the 
-            configured handler (static file, CGI, proxy, etc.) would have 
-            returned.</p> </li>
+            <em>does not</em> return information about the status code the
+            configured handler (static file, CGI, proxy, etc.) would have
+            returned.</p> </dd>
 
-            <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
-            permissions)<br />
+            <dt><strong>-x</strong></dt>
+            <dd>Has e<strong>x</strong>ecutable permissions.<br />
             Treats the <em>TestString</em> as a pathname and tests
             whether or not it exists, and has executable permissions.
             These permissions are determined according to
-            the underlying OS.</li>
+            the underlying OS.</dd>
+
+          </dl>
+
+          For example:
+
+        <pre class="prettyprint lang-config">RewriteCond /var/www/%{REQUEST_URI} !-f
+RewriteRule ^(.+) /other/archive/$1 [R]</pre>
 
-          </ul>
 
         </li>
 
-       <li>
+        <li>
            <p>If the <em>TestString</em> has the special value <code>expr</code>, the
            <em>CondPattern</em> will be treated as an
            <a href="../expr.html">ap_expr</a>.</p>
@@ -648,18 +682,18 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
             to block unwanted hotlinking.
            </p>
 
-           <pre class="prettyprint lang-config">           RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
-           RewriteRule ^/images - [F]</pre>
+           <pre class="prettyprint lang-config">RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
+RewriteRule "^/images" "-" [F]</pre>
 
         </li>
+     </ol>
 
-        <li>You can also set special flags for
-      <em>CondPattern</em> by appending
+     <p>You can also set special flags for <em>CondPattern</em> by appending
         <strong><code>[</code><em>flags</em><code>]</code></strong>
       as the third argument to the <code>RewriteCond</code>
       directive, where <em>flags</em> is a comma-separated list of any of the
-      following flags:
-
+      following flags:</p>
+      
       <ul>
         <li>'<strong><code>nocase|NC</code></strong>'
         (<strong>n</strong>o <strong>c</strong>ase)<br />
@@ -676,9 +710,9 @@ AliasMatch "^/myapp" "/opt/myapp-1.2.3"
           Use this to combine rule conditions with a local OR
           instead of the implicit AND. Typical example:
 
-<pre class="prettyprint lang-config">RewriteCond %{REMOTE_HOST}  ^host1  [OR]
-RewriteCond %{REMOTE_HOST}  ^host2  [OR]
-RewriteCond %{REMOTE_HOST}  ^host3
+<pre class="prettyprint lang-config">RewriteCond "%{REMOTE_HOST}"  "^host1"  [OR]
+RewriteCond "%{REMOTE_HOST}"  "^host2"  [OR]
+RewriteCond "%{REMOTE_HOST}"  "^host3"
 RewriteRule ...some special stuff for any of these hosts...</pre>
 
 
@@ -696,8 +730,6 @@ RewriteRule ...some special stuff for any of these hosts...</pre>
         is well understood.
         </li>
       </ul>
-      </li>
-     </ol>
 
       <p><strong>Example:</strong></p>
 
@@ -705,10 +737,10 @@ RewriteRule ...some special stuff for any of these hosts...</pre>
         ``<code>User-Agent:</code>'' header of the request, you can
         use the following: </p>
 
-<pre class="prettyprint lang-config">RewriteCond  %{HTTP_USER_AGENT}  (iPhone|Blackberry|Android)
-RewriteRule  ^/$                 /homepage.mobile.html  [L]
+<pre class="prettyprint lang-config">RewriteCond  "%{HTTP_USER_AGENT}"  "(iPhone|Blackberry|Android)"
+RewriteRule  "^/$"                 "/homepage.mobile.html"  [L]
 
-RewriteRule  ^/$                 /homepage.std.html  [L]</pre>
+RewriteRule  "^/$"                 "/homepage.std.html"     [L]</pre>
 
 
         <p>Explanation: If you use a browser which identifies itself
@@ -745,9 +777,10 @@ RewriteRule  ^/$                 /homepage.std.html  [L]</pre>
       <code>RewriteEngine on</code> directive for each virtual host
       in which you wish to use rewrite rules.</p>
 
-      <p><code class="directive">RewriteMap</code> directives of the type <code>prg</code>
+      <p><code class="directive"><a href="#rewritemap">RewriteMap</a></code> directives
+      of the type <code>prg</code>
       are not started during server initialization if they're defined in a
-      context that does not have <code class="directive">RewriteEngine</code>  set to
+      context that does not have <code class="directive">RewriteEngine</code> set to
       <code>on</code></p>
 
 </div>
@@ -793,13 +826,13 @@ RewriteRule  ^/$                 /homepage.std.html  [L]</pre>
       <p>For example, you might define a
       <code class="directive">RewriteMap</code> as:</p>
 
-      <pre class="prettyprint lang-config">RewriteMap examplemap txt:/path/to/file/map.txt</pre>
+      <pre class="prettyprint lang-config">RewriteMap examplemap "txt:/path/to/file/map.txt"</pre>
 
 
       <p>You would then be able to use this map in a
       <code class="directive">RewriteRule</code> as follows:</p>
 
-      <pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1}</pre>
+      <pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1}"</pre>
 
 
       <p>The meaning of the <em>MapTypeOptions</em> argument depends on
@@ -926,7 +959,7 @@ RewriteRule  ^/$                 /homepage.std.html  [L]</pre>
       directory on disk but lack a trailing slash, in the expectation that
       the <code class="module"><a href="../mod/mod_dir.html">mod_dir</a></code> module will issue the client with a redirect to
       the canonical URL with a trailing slash.</p>
-      
+
       <p>When the <code class="directive"><a href="../mod/mod_dir.html#directoryslash">DirectorySlash</a></code> directive
       is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
       that rewrite rules are no longer ignored. This option makes it possible to
@@ -953,7 +986,7 @@ RewriteRule  ^/$                 /homepage.std.html  [L]</pre>
       Available in Apache HTTP Server 2.4.3 and later.</p>
 
       <div class="warning">
-      <h3>Security Warning</h3> 
+      <h3>Security Warning</h3>
 
       <p>Enabling this option will make the server vulnerable to
       security issues if used with rewrite rules which are not
@@ -980,10 +1013,28 @@ RewriteRule  ^/$                 /homepage.std.html  [L]</pre>
 
       <p>When a relative substitution is made
          in directory (htaccess) context and <code class="directive"><a href="#rewritebase">RewriteBase</a></code> has not been set, this module uses some
-         extended URL and filesystem context information to change the 
-         relative substitution back into a URL. Modules such as 
+         extended URL and filesystem context information to change the
+         relative substitution back into a URL. Modules such as
          <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code> and <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code>
-         supply this extended context info.  </p>
+         supply this extended context info.  Available in 2.4.16 and later.</p>
+      </dd>
+
+
+      <dt><code>LegacyPrefixDocRoot</code></dt>
+      <dd>
+
+      <p>Prior to 2.4.26, if a substitution was an absolute URL that matched
+         the current virtual host, the URL might first be reduced to a URL-path
+         and then later reduced to a local path. Since the URL can be reduced 
+         to a local path, the path should be prefixed with the document root. 
+         This prevents a file such as /tmp/myfile from being accessed when a 
+         request is made to http://host/file/myfile with the following 
+         <code class="directive"><a href="#rewriterule">RewriteRule</a></code>.</p>
+      <pre class="prettyprint lang-config">RewriteRule /file/(.*) http://localhost/tmp/$1</pre>
+
+      <p>This option allows the old behavior to be used where the document
+         root is not prefixed to a local path that was reduced from a 
+         URL.  Available in 2.4.26 and later.</p>
       </dd>
 
       </dl>
@@ -1008,28 +1059,40 @@ RewriteRule  ^/$                 /homepage.std.html  [L]</pre>
 
       <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
       a perl compatible <a id="regexp" name="regexp">regular
-      expression</a>. On the first RewriteRule, it is matched against
-      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 <code class="directive">RewriteRule</code> directive is defined. </p>
 
 <div class="note"><h3><a id="what_is_matched" name="what_is_matched">What is matched?</a></h3>
-      <p>In <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> 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").</p>
 
-      <p>In <code class="directive"><a href="../mod/core.html#directory">Directory</a></code> and htaccess context,
-      the <em>Pattern</em> will initially be matched against the
-      <em>filesystem</em> path, after removing the prefix that led the server
-      to the current <code class="directive">RewriteRule</code> (e.g. "app1/index.html"
-      or "index.html" depending on where the directives are defined).</p>
+<ul>
+      <li><p>In <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> 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 per-directory context (<code class="directive"><a href="../mod/core.html#directory">Directory</a></code> 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 where the <code class="directive">RewriteRule</code> is 
+      defined.</p>
+
+      <p>The directory path where the rule is defined is stripped from the currently mapped
+      filesystem path before comparison (up to and including a trailing slash). 
+      The net result of this per-directory prefix stripping is that rules in
+      this context only match against the portion of the currently mapped filesystem path 
+      "below" where the rule is defined.</p>
+
+      <p>Directives such as <code class="directive">DocumentRoot</code> and <code class="directive">Alias</code>, or even the 
+      result of previous <code class="directive">RewriteRule</code> substitutions, determine
+      the currently mapped filesystem path.  
+      </p>
+      </li>
 
-      <p>If you wish to match against the hostname, port, or query string, use a
+      <li><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.</p></li>
+</ul>
 </div>
 
 <div class="note"><h3>Per-directory Rewrites</h3>
@@ -1044,18 +1107,13 @@ administrator has disabled override of <code>FollowSymLinks</code> for
 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 <code class="directive"><a href="#rewritebase">RewriteBase</a></code>
+<li>See the <code class="directive"><a href="#rewritebase">RewriteBase</a></code>
 directive for more information regarding what prefix will be added back to
 relative substitutions.</li>
 
 <li> If you wish to match against the full URL-path in a per-directory
 (htaccess) RewriteRule, use the <code>%{REQUEST_URI}</code> variable in
-a <code class="directive">RewriteCond</code>.</li>
+a <code class="directive"><a href="#rewritecond">RewriteCond</a></code>.</li>
 
 <li>The removed prefix always ends with a slash, meaning the matching occurs against a string which
 <em>never</em> has a leading slash.  Therefore, a <em>Pattern</em> with <code>^/</code> never
@@ -1100,7 +1158,7 @@ cannot use <code>$N</code> in the substitution string!
 
         <dd>Designates the location on the file-system of the resource
         to be delivered to the client.  Substitutions are only
-        treated as a file-system path when the rule is configured in 
+        treated as a file-system path when the rule is configured in
         server (virtualhost) context and the first component of the
         path in the substitution exists in the file-system</dd>
 
@@ -1114,7 +1172,7 @@ cannot use <code>$N</code> in the substitution string!
         you specify a <em>Substitution</em> string of
         <code>/www/file.html</code>, then this will be treated as a
         URL-path <em>unless</em> a directory named <code>www</code>
-        exists at the root or your file-system (or, in the case of 
+        exists at the root or your file-system (or, in the case of
         using rewrites in a <code>.htaccess</code> file, relative to
         your document root), in which case it will
         be treated as a file-system path. If you wish other
@@ -1162,9 +1220,11 @@ cannot use <code>$N</code> in the substitution string!
       (<strong>N</strong>=0..9), which will be replaced
       by the contents of the <strong>N</strong>th group of the
       matched <em>Pattern</em>. The server-variables are the same
-      as for the <em>TestString</em> of a <code>RewriteCond</code>
+      as for the <em>TestString</em> of a
+      <code class="directive"><a href="#rewritecond">RewriteCond</a></code>
       directive. The mapping-functions come from the
-      <code>RewriteMap</code> directive and are explained there.
+      <code class="directive"><a href="#rewritemap">RewriteMap</a></code>
+      directive and are explained there.
       These three types of variables are expanded in the order above.</p>
 
       <p>Rewrite rules are applied to the results of previous rewrite
@@ -1191,7 +1251,7 @@ cannot use <code>$N</code> in the substitution string!
 
       <p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
       appending <strong><code>[</code><em>flags</em><code>]</code></strong>
-      as the third argument to the <code>RewriteRule</code>
+      as the third argument to the <code class="directive">RewriteRule</code>
       directive. <em>Flags</em> is a comma-separated list, surround by square
       brackets, of any of the flags in the following table. More
       details, and examples, for each flag, are available in the <a href="../rewrite/flags.html">Rewrite Flags document</a>.</p>
@@ -1201,12 +1261,12 @@ cannot use <code>$N</code> in the substitution string!
     </tr>
 <tr>
         <td>B</td>
-        <td>Escape non-alphanumeric characters in backreferences <em>before</em> 
+        <td>Escape non-alphanumeric characters in backreferences <em>before</em>
         applying the transformation. <em><a href="../rewrite/flags.html#flag_b">details ...</a></em></td>
     </tr>
 <tr class="odd">
         <td>backrefnoplus|BNP</td>
-        <td>If backreferences are being escaped, spaces should be escaped to 
+        <td>If backreferences are being escaped, spaces should be escaped to
         %20 instead of +. Useful when the backreference will be used in the
         path component rather than the query string.<em><a href="../rewrite/flags.html#flag_bnp">details ...</a></em></td>
     </tr>
@@ -1298,7 +1358,7 @@ cannot use <code>$N</code> in the substitution string!
     </tr>
 <tr class="odd">
         <td>qsappend|QSA</td>
-        <td>Appends any query string from the original request URL to 
+        <td>Appends any query string from the original request URL to
         any query string created in the rewrite target.<em><a href="../rewrite/flags.html#flag_qsa">details ...</a></em></td>
     </tr>
 <tr>
@@ -1308,17 +1368,25 @@ cannot use <code>$N</code> in the substitution string!
         ...</a></em></td>
     </tr>
 <tr class="odd">
+        <td>qslast|QSL</td>
+        <td>Interpret the last (right-most) question mark as the query string
+            delimiter, instead of the first (left-most) as normally used.  
+            Available in 2.4.19 and later.
+        <em><a href="../rewrite/flags.html#flag_qsl">details
+        ...</a></em></td>
+    </tr>
+<tr>
         <td>redirect|R[=<em>code</em>]</td>
         <td>Forces an external redirect, optionally with the specified
         HTTP status code. <em><a href="../rewrite/flags.html#flag_r">details ...</a></em>
         </td>
     </tr>
-<tr>
+<tr class="odd">
         <td>skip|S=<em>num</em></td>
         <td>Tells the rewriting engine to skip the next <em>num</em>
         rules if the current rule matches. <em><a href="../rewrite/flags.html#flag_s">details ...</a></em></td>
     </tr>
-<tr class="odd">
+<tr>
         <td>type|T=<em>MIME-type</em></td>
         <td>Force the <a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file
         to be the specified type. <em><a href="../rewrite/flags.html#flag_t">details ...</a></em></td>
@@ -1403,7 +1471,7 @@ directive.</p>
       <p><strong>Inside per-directory configuration for
       <code>/somepath</code><br />
        (<code>/physical/path/to/somepath/.htaccess</code>, with
-      <code>RewriteBase /somepath</code>)<br />
+      <code>RewriteBase "/somepath"</code>)<br />
        for request ``<code>GET
       /somepath/localpath/pathinfo</code>'':</strong><br />
      </p>
@@ -1487,7 +1555,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_rewrite.ht
     }
 })(window, document);
 //--><!]]></script></div><div id="footer">
-<p class="apache">Copyright 2015 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="apache">Copyright 2017 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
 if (typeof(prettyPrint) !== 'undefined') {
     prettyPrint();