]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_rewrite.html.en
Rebuild all
[apache] / docs / manual / mod / mod_rewrite.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7               This file is generated from xml source: DO NOT EDIT
8         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9       -->
10 <title>mod_rewrite - Apache HTTP Server Version 2.5</title>
11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
14 <script src="../style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
18 <body>
19 <div id="page-header">
20 <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>
21 <p class="apache">Apache HTTP Server Version 2.5</p>
22 <img alt="" src="../images/feather.png" /></div>
23 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
24 <div id="path">
25 <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>
26 <div id="page-content">
27 <div id="preamble"><h1>Apache Module mod_rewrite</h1>
28 <div class="toplang">
29 <p><span>Available Languages: </span><a href="../en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
30 <a href="../fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
31 </div>
32 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
33 URLs on the fly</td></tr>
34 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
35 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>rewrite_module</td></tr>
36 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_rewrite.c</td></tr></table>
37 <h3>Summary</h3>
38
39         <p>The <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> module uses a rule-based rewriting
40       engine, based on a PCRE regular-expression parser, to rewrite requested URLs on
41       the fly. By default, <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> maps a URL to a filesystem
42       path. However, it can also be used to redirect one URL to another URL, or
43       to invoke an internal proxy fetch.</p>
44       <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> provides a flexible and powerful way to
45       manipulate URLs using an unlimited number of rules. Each rule can have an
46       unlimited number of attached rule conditions, to allow you to rewrite URL
47       based on server variables, environment variables, HTTP headers, or time
48       stamps.</p>
49       <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> operates on the full URL path, including the
50       path-info section. A rewrite rule can be invoked in
51       <code>httpd.conf</code> or in <code>.htaccess</code>. The path generated
52       by a rewrite rule can include a query string, or can lead to internal
53       sub-processing, external request redirection, or internal proxy
54       throughput.</p>
55
56       <p>Further details, discussion, and examples, are provided in the
57       <a href="../rewrite/">detailed mod_rewrite documentation</a>.</p>
58 </div>
59 <div id="quickview"><h3>Topics</h3>
60 <ul id="topics">
61 <li><img alt="" src="../images/down.gif" /> <a href="#logging">Logging</a></li>
62 </ul><h3 class="directives">Directives</h3>
63 <ul id="toc">
64 <li><img alt="" src="../images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
65 <li><img alt="" src="../images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
66 <li><img alt="" src="../images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
67 <li><img alt="" src="../images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
68 <li><img alt="" src="../images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
69 <li><img alt="" src="../images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
70 </ul>
71 <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>
72 <ul class="seealso">
73 <li><a href="#comments_section">Comments</a></li></ul></div>
74 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
75 <div class="section">
76 <h2><a name="logging" id="logging">Logging</a></h2>
77
78     <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> offers detailed logging of its actions
79     at the <code>trace1</code> to <code>trace8</code> log levels. The
80     log level can be set specifically for <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
81     using the <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code> directive: Up to
82     level <code>debug</code>, no actions are logged, while <code>trace8</code>
83     means that practically all actions are logged.</p>
84
85     <div class="note">
86       Using a high trace log level for <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
87       will slow down your Apache HTTP Server dramatically! Use a log
88       level higher than <code>trace2</code> only for debugging!
89     </div>
90
91     <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">LogLevel alert rewrite:trace3</pre>
92 </div>
93
94     <div class="note"><h3>RewriteLog</h3>
95       <p>Those familiar with earlier versions of
96       <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> will no doubt be looking for the
97       <code>RewriteLog</code> and <code>RewriteLogLevel</code>
98       directives. This functionality has been completely replaced by the
99       new per-module logging configuration mentioned above.
100       </p>
101
102       <p>To get just the <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>-specific log
103       messages, pipe the log file through grep:</p>
104     <div class="example"><p><code>
105     tail -f error_log|fgrep '[rewrite:'
106     </code></p></div>
107     </div>
108
109 </div>
110 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
111 <div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
112 <table class="directive">
113 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
114 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
115 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>None</code></td></tr>
116 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
117 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
118 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
119 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
120 </table>
121       <p>The <code class="directive">RewriteBase</code> directive specifies the
122       URL prefix to be used for per-directory (htaccess)
123       <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives that
124       substitute a relative path.</p>
125       <p> This directive is <em>required</em> when you use a relative path
126       in a substitution in per-directory (htaccess) context unless any 
127       of the following conditions are true:</p>
128       <ul>
129           <li> The original request, and the substitution, are underneath the
130                <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>
131                (as opposed to reachable by other means, such as
132                <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>).</li>
133           <li> The <em>filesystem</em> path to the directory containing the
134                <code class="directive"><a href="#rewriterule">RewriteRule</a></code>,
135                suffixed by the relative
136                substitution is also valid as a URL path on the server
137                (this is rare).</li>
138           <li> In Apache HTTP Server 2.4.16 and later, this directive may be
139                 omitted when the request is mapped via
140                 <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>
141                 or <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code>.</li>
142       </ul>
143
144 <p> In the example below, <code class="directive">RewriteBase</code> is necessary
145     to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
146     since the resource was not relative to the document root.  This
147     misconfiguration would normally cause the server to look for an "opt"
148     directory under the document root.</p>
149 <pre class="prettyprint lang-config">DocumentRoot "/var/www/example.com"
150 AliasMatch "^/myapp" "/opt/myapp-1.2.3"
151 &lt;Directory "/opt/myapp-1.2.3"&gt;
152     RewriteEngine On
153     RewriteBase "/myapp/"
154     RewriteRule "^index\.html$"  "welcome.html"
155 &lt;/Directory&gt;</pre>
156
157
158
159 </div>
160 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
161 <div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
162 <table class="directive">
163 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
164 </td></tr>
165 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
166       <em>TestString</em> <em>CondPattern</em></code></td></tr>
167 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
168 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
169 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
170 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
171 </table>
172       <p>The <code class="directive">RewriteCond</code> directive defines a
173       rule condition. One or more <code class="directive">RewriteCond</code>
174       can precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
175       directive. The following rule is then only used if both
176       the current state of the URI matches its pattern, <strong>and</strong> if these conditions are met.</p>
177
178       <p><em>TestString</em> is a string which can contain the
179       following expanded constructs in addition to plain text:</p>
180
181       <ul>
182         <li>
183           <strong>RewriteRule backreferences</strong>: These are
184           backreferences of the form <strong><code>$N</code></strong>
185           (0 &lt;= N &lt;= 9). $1 to $9 provide access to the grouped
186           parts (in parentheses) of the pattern, from the
187           <code>RewriteRule</code> which is subject to the current
188           set of <code>RewriteCond</code> conditions. $0 provides
189           access to the whole string matched by that pattern.
190         </li>
191         <li>
192           <strong>RewriteCond backreferences</strong>: These are
193           backreferences of the form <strong><code>%N</code></strong>
194           (0 &lt;= N &lt;= 9). %1 to %9 provide access to the grouped
195           parts (again, in parentheses) of the pattern, from the last matched
196           <code>RewriteCond</code> in the current set
197           of conditions. %0 provides access to the whole string matched by
198           that pattern.
199         </li>
200         <li>
201           <strong>RewriteMap expansions</strong>: These are
202           expansions of the form <strong><code>${mapname:key|default}</code></strong>.
203           See <a href="#mapfunc">the documentation for
204           RewriteMap</a> for more details.
205         </li>
206         <li>
207           <strong>Server-Variables</strong>: These are variables of
208           the form
209             <strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
210             <code>}</code></strong>
211           where <em>NAME_OF_VARIABLE</em> can be a string taken
212           from the following list:
213
214           <table>
215           
216             <tr>
217               <th>HTTP headers:</th> <th>connection &amp; request:</th> <th />
218             </tr>
219
220             <tr>
221               <td>
222                  HTTP_ACCEPT<br />
223                  HTTP_COOKIE<br />
224                  HTTP_FORWARDED<br />
225                  HTTP_HOST<br />
226                  HTTP_PROXY_CONNECTION<br />
227                  HTTP_REFERER<br />
228                  HTTP_USER_AGENT<br />
229               </td>
230
231               <td>
232                  AUTH_TYPE<br />
233                  CONN_REMOTE_ADDR<br />
234                  CONTEXT_PREFIX<br />
235                  CONTEXT_DOCUMENT_ROOT<br />
236                  IPV6<br />
237                  PATH_INFO<br />
238                  QUERY_STRING<br />
239                  REMOTE_ADDR<br />
240                  REMOTE_HOST<br />
241                  REMOTE_IDENT<br />
242                  REMOTE_PORT<br />
243                  REMOTE_USER<br />
244                  REQUEST_METHOD<br />
245                  SCRIPT_FILENAME<br />
246               </td>
247
248               <td />
249             </tr>
250
251             <tr>
252               <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
253             </tr>
254
255             <tr>
256               <td>
257                  DOCUMENT_ROOT<br />
258                  SCRIPT_GROUP<br />
259                  SCRIPT_USER<br />
260                  SERVER_ADDR<br />
261                  SERVER_ADMIN<br />
262                  SERVER_NAME<br />
263                  SERVER_PORT<br />
264                  SERVER_PROTOCOL<br />
265                  SERVER_SOFTWARE<br />
266               </td>
267
268               <td>
269                  TIME_YEAR<br />
270                  TIME_MON<br />
271                  TIME_DAY<br />
272                  TIME_HOUR<br />
273                  TIME_MIN<br />
274                  TIME_SEC<br />
275                  TIME_WDAY<br />
276                  TIME<br />
277               </td>
278
279               <td>
280                  API_VERSION<br />
281                  CONN_REMOTE_ADDR<br />
282                  HTTPS<br />
283                  IS_SUBREQ<br />
284                  REMOTE_ADDR<br />
285                  REQUEST_FILENAME<br />
286                  REQUEST_SCHEME<br />
287                  REQUEST_URI<br />
288                  THE_REQUEST<br />
289               </td>
290             </tr>
291           </table>
292
293                 <p>These variables all
294                 correspond to the similarly named HTTP
295                 MIME-headers, C variables of the Apache HTTP Server or
296                 <code>struct tm</code> fields of the Unix system.
297                 Most are documented <a href="../expr.html#vars">here</a>
298                 or elsewhere in the Manual or in the CGI specification.</p>
299
300                 <p>SERVER_NAME and SERVER_PORT depend on the values of
301                 <code class="directive"><a href="../mod/core.html#usecanonicalname">UseCanonicalName</a></code> and
302                 <code class="directive"><a href="../mod/core.html#usecanonicalphysicalport">UseCanonicalPhysicalPort</a></code>
303                 respectively.</p>
304
305                 <p>Those that are special to mod_rewrite include those below.</p>
306                 <dl>
307                   <dt><code>API_VERSION</code></dt>
308
309                   <dd>This is the version of the Apache httpd module API
310                   (the internal interface between server and
311                   module) in the current httpd build, as defined in
312                   include/ap_mmn.h. The module API version
313                   corresponds to the version of Apache httpd in use (in
314                   the release version of Apache httpd 1.3.14, for
315                   instance, it is 19990320:10), but is mainly of
316                   interest to module authors.</dd>
317
318                   <dt><code>CONN_REMOTE_ADDR</code></dt>
319
320                   <dd>Since 2.4.8: The peer IP address of the connection (see the
321                   <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> module).</dd>
322
323                   <dt><code>HTTPS</code></dt>
324
325                   <dd>Will contain the text "on" if the connection is
326                   using SSL/TLS, or "off" otherwise.  (This variable
327                   can be safely used regardless of whether or not
328                   <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
329
330                   <dt><code>IS_SUBREQ</code></dt>
331
332                   <dd>Will contain the text "true" if the request
333                   currently being processed is a sub-request,
334                   "false" otherwise. Sub-requests may be generated
335                   by modules that need to resolve additional files
336                   or URIs in order to complete their tasks.</dd>
337
338                   <dt><code>REMOTE_ADDR</code></dt>
339
340                   <dd>The IP address of the remote host (see the
341                   <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> module).</dd>
342
343                   <dt><code>REQUEST_FILENAME</code></dt>
344
345                   <dd>The full local filesystem path to the file or
346                   script matching the request, if this has already
347                   been determined by the server at the time
348                   <code>REQUEST_FILENAME</code> is referenced. Otherwise,
349                   such as when used in virtual host context, the same
350                   value as <code>REQUEST_URI</code>.  Depending on the value of
351                   <code class="directive"><a href="../mod/core.html#acceptpathinfo">AcceptPathInfo</a></code>, the
352                   server may have only used some leading components of the
353                   <code>REQUEST_URI</code> to map the request to a file.
354                   </dd>
355
356                   <dt><code>REQUEST_SCHEME</code></dt>
357
358                   <dd>Will contain the scheme of the request (usually
359                   "http" or "https"). This value can be influenced with
360                   <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>.</dd>
361
362                   <dt><code>REQUEST_URI</code></dt>
363
364                   <dd>The path component of the requested URI,
365                   such as "/index.html".  This notably excludes the
366                   query string which is available as its own variable
367                   named <code>QUERY_STRING</code>.</dd>
368
369                   <dt><code>THE_REQUEST</code></dt>
370
371                   <dd>The full HTTP request line sent by the
372                   browser to the server (e.g., "<code>GET
373                   /index.html HTTP/1.1</code>"). This does not
374                   include any additional headers sent by the
375                   browser.  This value has not been unescaped
376                   (decoded), unlike most other variables below.</dd>
377
378                 </dl>
379         </li>
380       </ul>
381
382       <p>If the <em>TestString</em> has the special value <code>expr</code>,
383       the <em>CondPattern</em> will be treated as an
384       <a href="../expr.html">ap_expr</a>. HTTP headers referenced in the
385       expression will be added to the Vary header if the <code>novary</code>
386       flag is not given.</p>
387
388       <p>Other things you should be aware of:</p>
389
390       <ol>
391         <li>
392         <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
393         contain the same value - the value of the
394         <code>filename</code> field of the internal
395         <code>request_rec</code> structure of the Apache HTTP Server.
396         The first name is the commonly known CGI variable name
397         while the second is the appropriate counterpart of
398         REQUEST_URI (which contains the value of the
399         <code>uri</code> field of <code>request_rec</code>).</p>
400         <p>If a substitution occurred and the rewriting continues,
401         the value of both variables will be updated accordingly.</p>
402         <p>If used in per-server context (<em>i.e.</em>, before the
403         request is mapped to the filesystem) SCRIPT_FILENAME and
404         REQUEST_FILENAME cannot contain the full local filesystem
405         path since the path is unknown at this stage of processing.
406         Both variables will initially contain the value of REQUEST_URI
407         in that case. In order to obtain the full local filesystem
408         path of the request in per-server context, use an URL-based
409         look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
410         the final value of REQUEST_FILENAME.</p></li>
411
412         <li>
413         <code>%{ENV:variable}</code>, where <em>variable</em> can be
414         any environment variable, is also available.
415         This is looked-up via internal
416         Apache httpd structures and (if not found there) via
417         <code>getenv()</code> from the Apache httpd server process.</li>
418
419         <li>
420         <code>%{SSL:variable}</code>, where <em>variable</em> is the
421         name of an <a href="mod_ssl.html#envvars">SSL environment
422         variable</a>, can be used whether or not
423         <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
424         the empty string if it is not.  Example:
425         <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
426         <code>128</code>. These variables are available even without
427         setting the <code>StdEnvVars</code> option of the
428         <code class="directive"><a href="../mod/mod_ssl.html#ssloptions">SSLOptions</a></code> directive.</li>
429
430         <li>
431         <code>%{HTTP:header}</code>, where <em>header</em> can be
432         any HTTP MIME-header name, can always be used to obtain the
433         value of a header sent in the HTTP request.
434         Example: <code>%{HTTP:Proxy-Connection}</code> is
435         the value of the HTTP header
436         ``<code>Proxy-Connection:</code>''.
437         <p>If a HTTP header is used in a condition this header is added to
438         the Vary header of the response in case the condition evaluates
439         to true for the request. It is <strong>not</strong> added if the
440         condition evaluates to false for the request. Adding the HTTP header
441         to the Vary header of the response is needed for proper caching.</p>
442         <p>It has to be kept in mind that conditions follow a short circuit
443         logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
444         so that certain conditions might not be evaluated at all.</p></li>
445
446         <li>
447         <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
448         can be used for look-aheads which perform
449         an internal (URL-based) sub-request to determine the final
450         value of <em>variable</em>. This can be used to access
451         variable for rewriting which is not available at the current
452         stage, but will be set in a later phase.
453         <p>For instance, to rewrite according to the
454         <code>REMOTE_USER</code> variable from within the
455         per-server context (<code>httpd.conf</code> file) you must
456         use <code>%{LA-U:REMOTE_USER}</code> - this
457         variable is set by the authorization phases, which come
458         <em>after</em> the URL translation phase (during which mod_rewrite
459         operates).</p>
460         <p>On the other hand, because mod_rewrite implements
461         its per-directory context (<code>.htaccess</code> file) via
462         the Fixup phase of the API and because the authorization
463         phases come <em>before</em> this phase, you just can use
464         <code>%{REMOTE_USER}</code> in that context.</p></li>
465
466         <li>
467         <code>%{LA-F:variable}</code> can be used to perform an internal
468         (filename-based) sub-request, to determine the final value
469         of <em>variable</em>. Most of the time, this is the same as
470         LA-U above.</li>
471       </ol>
472
473       <p><em>CondPattern</em> is the condition pattern,
474        a regular expression which is applied to the
475       current instance of the <em>TestString</em>.
476       <em>TestString</em> is first evaluated, before being matched against
477       <em>CondPattern</em>.</p>
478
479       <p><em>CondPattern</em> is usually a
480       <em>perl compatible regular expression</em>, but there is
481       additional syntax available to perform other useful tests against
482       the <em>Teststring</em>:</p>
483
484       <ol>
485         <li>You can prefix the pattern string with a
486         '<code>!</code>' character (exclamation mark) to negate the result
487         of the condition, no matter what kind of <em>CondPattern</em> is used.
488         </li>
489
490         <li>
491           You can perform lexicographical string comparisons:
492
493           <dl>
494             <dt><strong>&lt;CondPattern</strong></dt>
495             <dd>Lexicographically precedes<br />
496             Treats the <em>CondPattern</em> as a plain string and
497             compares it lexicographically to <em>TestString</em>. True if
498             <em>TestString</em> lexicographically precedes
499             <em>CondPattern</em>.</dd>
500
501             <dt><strong>&gt;CondPattern</strong></dt>
502             <dd>Lexicographically follows<br />
503             Treats the <em>CondPattern</em> as a plain string and
504             compares it lexicographically to <em>TestString</em>. True if
505             <em>TestString</em> lexicographically follows
506             <em>CondPattern</em>.</dd>
507
508             <dt><strong>=CondPattern</strong></dt>
509             <dd>Lexicographically equal<br />
510             Treats the <em>CondPattern</em> as a plain string and
511             compares it lexicographically to <em>TestString</em>. True if
512             <em>TestString</em> is lexicographically equal to
513             <em>CondPattern</em> (the two strings are exactly
514             equal, character for character). If <em>CondPattern</em>
515             is <code>""</code> (two quotation marks) this
516             compares <em>TestString</em> to the empty string.</dd>
517
518             <dt><strong>&lt;=CondPattern</strong></dt>
519             <dd>Lexicographically less than or equal to<br />
520             Treats the <em>CondPattern</em> as a plain string and
521             compares it lexicographically to <em>TestString</em>. True
522             if <em>TestString</em> lexicographically precedes
523             <em>CondPattern</em>, or is equal to <em>CondPattern</em>
524             (the two strings are equal, character for character).</dd>
525
526             <dt><strong>&gt;=CondPattern</strong></dt>
527             <dd>Lexicographically greater than or equal to<br />
528             Treats the <em>CondPattern</em> as a plain string and
529             compares it lexicographically to <em>TestString</em>. True
530             if <em>TestString</em> lexicographically follows
531             <em>CondPattern</em>, or is equal to <em>CondPattern</em>
532             (the two strings are equal, character for character).</dd>
533         </dl>
534         </li>
535
536         <li>
537           You can perform integer comparisons:
538           <dl>
539
540             <dt><strong>-eq</strong></dt>
541             <dd>Is numerically <strong>eq</strong>ual to<br />
542             The <em>TestString</em> is treated as an integer, and is
543             numerically compared to the <em>CondPattern</em>. True if
544             the two are numerically equal.</dd>
545
546             <dt><strong>-ge</strong></dt>
547             <dd>Is numerically <strong>g</strong>reater than or <strong>e</strong>qual to<br />
548             The <em>TestString</em> is treated as an integer, and is
549             numerically compared to the <em>CondPattern</em>. True if
550             the <em>TestString</em> is numerically greater than or equal
551             to the <em>CondPattern</em>.</dd>
552
553             <dt><strong>-gt</strong></dt>
554             <dd>Is numerically <strong>g</strong>reater <strong>t</strong>han<br />
555             The <em>TestString</em> is treated as an integer, and is
556             numerically compared to the <em>CondPattern</em>. True if
557             the <em>TestString</em> is numerically greater than
558             the <em>CondPattern</em>.</dd>
559
560             <dt><strong>-le</strong></dt>
561             <dd>Is numerically <strong>l</strong>ess than or <strong>e</strong>qual to<br />
562             The <em>TestString</em> is treated as an integer, and is
563             numerically compared to the <em>CondPattern</em>. True if
564             the <em>TestString</em> is numerically less than or equal
565             to the <em>CondPattern</em>. Avoid confusion with the
566             <strong>-l</strong> by using the <strong>-L</strong> or
567             <strong>-h</strong> variant.</dd>
568
569             <dt><strong>-lt</strong></dt>
570             <dd>Is numerically <strong>l</strong>ess <strong>t</strong>han<br />
571             The <em>TestString</em> is treated as an integer, and is
572             numerically compared to the <em>CondPattern</em>. True if
573             the <em>TestString</em> is numerically less than
574             the <em>CondPattern</em>. Avoid confusion with the
575             <strong>-l</strong> by using the <strong>-L</strong> or
576             <strong>-h</strong> variant.</dd>
577
578             <dt><strong>-ne</strong></dt>
579             <dd>Is numerically <strong>n</strong>ot <strong>e</strong>qual to<br />
580             The <em>TestString</em> is treated as an integer, and is
581             numerically compared to the <em>CondPattern</em>. True if
582             the two are numerically different. This is equivalent to
583             <code>!-eq</code>.</dd>
584
585            </dl>
586         </li>
587
588         <li>You can perform various file attribute tests:
589
590
591           <dl>
592
593           <dt><strong>-d</strong></dt>
594
595           <dd>Is <strong>d</strong>irectory.<br />
596              Treats the <em>TestString</em> as a pathname and tests
597             whether or not it exists, and is a directory.
598           </dd>
599
600           <dt><strong>-f</strong></dt>
601
602           <dd>Is regular <strong>f</strong>ile.<br />
603
604              Treats the <em>TestString</em> as a pathname and tests
605             whether or not it exists, and is a regular file.
606         </dd>
607
608            <dt><strong>-F</strong></dt>
609
610            <dd>Is existing file, via subrequest.<br />
611             Checks whether or not <em>TestString</em> is a valid file,
612             accessible via all the server's currently-configured
613             access controls for that path. This uses an internal
614             subrequest to do the check, so use it with care -
615             it can impact your server's performance!
616            </dd>
617
618             <dt><strong>-h</strong></dt>
619             <dd>Is symbolic link, bash convention.<br />
620             See <strong>-l</strong>.
621             </dd>
622
623             <dt><strong>-l</strong></dt>
624
625             <dd>Is symbolic <strong>l</strong>ink.<br />
626             Treats the <em>TestString</em> as a pathname and tests
627             whether or not it exists, and is a symbolic link. May also
628             use the bash convention of <strong>-L</strong> or
629             <strong>-h</strong> if there's a possibility of confusion
630             such as when using the <strong>-lt</strong> or
631             <strong>-le</strong> tests.
632             </dd>
633
634             <dt><strong>-L</strong></dt>
635             <dd>Is symbolic link, bash convention.<br />
636             See <strong>-l</strong>.</dd>
637
638             <dt><strong>-s</strong></dt>
639             <dd>Is regular file, with <strong>s</strong>ize.<br />
640             Treats the <em>TestString</em> as a pathname and tests
641             whether or not it exists, and is a regular file with size greater
642             than zero.</dd>
643
644             <dt><strong>-U</strong></dt>
645             <dd><p>Is existing URL, via subrequest.<br />
646             Checks whether or not <em>TestString</em> is a valid URL,
647             accessible via all the server's currently-configured
648             access controls for that path. This uses an internal
649             subrequest to do the check, so use it with care -
650             it can impact your server's performance!</p>
651             <p> This flag <em>only</em> returns information about things
652             like access control, authentication, and authorization.  This flag
653             <em>does not</em> return information about the status code the
654             configured handler (static file, CGI, proxy, etc.) would have
655             returned.</p> </dd>
656
657             <dt><strong>-x</strong></dt>
658             <dd>Has e<strong>x</strong>ecutable permissions.<br />
659             Treats the <em>TestString</em> as a pathname and tests
660             whether or not it exists, and has executable permissions.
661             These permissions are determined according to
662             the underlying OS.</dd>
663
664           </dl>
665
666           For example:
667
668         <pre class="prettyprint lang-config">RewriteCond /var/www/%{REQUEST_URI} !-f
669 RewriteRule ^(.+) /other/archive/$1 [R]</pre>
670
671
672         </li>
673
674         <li>
675            <p>If the <em>TestString</em> has the special value <code>expr</code>, the
676            <em>CondPattern</em> will be treated as an
677            <a href="../expr.html">ap_expr</a>.</p>
678
679            <p>
680             In the below example, <code>-strmatch</code> is used to
681             compare the <code>REFERER</code> against the site hostname,
682             to block unwanted hotlinking.
683            </p>
684
685            <pre class="prettyprint lang-config">RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
686 RewriteRule "^/images" "-" [F]</pre>
687
688         </li>
689
690         <li>You can also set special flags for
691       <em>CondPattern</em> by appending
692         <strong><code>[</code><em>flags</em><code>]</code></strong>
693       as the third argument to the <code>RewriteCond</code>
694       directive, where <em>flags</em> is a comma-separated list of any of the
695       following flags:
696
697       <ul>
698         <li>'<strong><code>nocase|NC</code></strong>'
699         (<strong>n</strong>o <strong>c</strong>ase)<br />
700         This makes the test case-insensitive - differences
701         between 'A-Z' and 'a-z' are ignored, both in the
702         expanded <em>TestString</em> and the <em>CondPattern</em>.
703         This flag is effective only for comparisons between
704         <em>TestString</em> and <em>CondPattern</em>. It has no
705         effect on filesystem and subrequest checks.</li>
706
707         <li>
708           '<strong><code>ornext|OR</code></strong>'
709           (<strong>or</strong> next condition)<br />
710           Use this to combine rule conditions with a local OR
711           instead of the implicit AND. Typical example:
712
713 <pre class="prettyprint lang-config">RewriteCond "%{REMOTE_HOST}"  "^host1"  [OR]
714 RewriteCond "%{REMOTE_HOST}"  "^host2"  [OR]
715 RewriteCond "%{REMOTE_HOST}"  "^host3"
716 RewriteRule ...some special stuff for any of these hosts...</pre>
717
718
719           Without this flag you would have to write the condition/rule
720           pair three times.
721         </li>
722
723         <li>'<strong><code>novary|NV</code></strong>'
724         (<strong>n</strong>o <strong>v</strong>ary)<br />
725         If a HTTP header is used in the condition, this flag prevents
726         this header from being added to the Vary header of the response. <br />
727         Using this flag might break proper caching of the response if
728         the representation of this response varies on the value of this header.
729         So this flag should be only used if the meaning of the Vary header
730         is well understood.
731         </li>
732       </ul>
733       </li>
734      </ol>
735
736       <p><strong>Example:</strong></p>
737
738        <p>To rewrite the Homepage of a site according to the
739         ``<code>User-Agent:</code>'' header of the request, you can
740         use the following: </p>
741
742 <pre class="prettyprint lang-config">RewriteCond  "%{HTTP_USER_AGENT}"  "(iPhone|Blackberry|Android)"
743 RewriteRule  "^/$"                 "/homepage.mobile.html"  [L]
744
745 RewriteRule  "^/$"                 "/homepage.std.html"     [L]</pre>
746
747
748         <p>Explanation: If you use a browser which identifies itself
749         as a mobile browser (note that the example is incomplete, as
750         there are many other mobile platforms), the mobile version of
751         the homepage is served. Otherwise, the standard page is served.
752         </p>
753
754
755 </div>
756 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
757 <div class="directive-section"><h2><a name="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2>
758 <table class="directive">
759 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
760 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr>
761 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr>
762 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
763 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
764 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
765 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
766 </table>
767
768       <p>The <code class="directive">RewriteEngine</code> directive enables or
769       disables the runtime rewriting engine. If it is set to
770       <code>off</code> this module does no runtime processing at
771       all. It does not even update the <code>SCRIPT_URx</code>
772       environment variables.</p>
773
774       <p>Use this directive to disable rules in a particular context,
775       rather than commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.</p>
776
777       <p>Note that rewrite configurations are not
778       inherited by virtual hosts. This means that you need to have a
779       <code>RewriteEngine on</code> directive for each virtual host
780       in which you wish to use rewrite rules.</p>
781
782       <p><code class="directive"><a href="#rewritemap">RewriteMap</a></code> directives
783       of the type <code>prg</code>
784       are not started during server initialization if they're defined in a
785       context that does not have <code class="directive">RewriteEngine</code> set to
786       <code>on</code></p>
787
788 </div>
789 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
790 <div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
791 <table class="directive">
792 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
793 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
794     <em>MapTypeOptions</em>
795 </code></td></tr>
796 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
797 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
798 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
799 </table>
800       <p>The <code class="directive">RewriteMap</code> directive defines a
801       <em>Rewriting Map</em> which can be used inside rule
802       substitution strings by the mapping-functions to
803       insert/substitute fields through a key lookup. The source of
804       this lookup can be of various types.</p>
805
806       <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is
807       the name of the map and will be used to specify a
808       mapping-function for the substitution strings of a rewriting
809       rule via one of the following constructs:</p>
810
811       <p class="indent">
812         <strong><code>${</code> <em>MapName</em> <code>:</code>
813         <em>LookupKey</em> <code>}</code><br />
814          <code>${</code> <em>MapName</em> <code>:</code>
815         <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
816         <code>}</code></strong>
817       </p>
818
819       <p>When such a construct occurs, the map <em>MapName</em> is
820       consulted and the key <em>LookupKey</em> is looked-up. If the
821       key is found, the map-function construct is substituted by
822       <em>SubstValue</em>. If the key is not found then it is
823       substituted by <em>DefaultValue</em> or by the empty string
824       if no <em>DefaultValue</em> was specified. Empty values
825       behave as if the key was absent, therefore it is not possible
826       to distinguish between empty-valued keys and absent keys.</p>
827
828       <p>For example, you might define a
829       <code class="directive">RewriteMap</code> as:</p>
830
831       <pre class="prettyprint lang-config">RewriteMap examplemap "txt:/path/to/file/map.txt"</pre>
832
833
834       <p>You would then be able to use this map in a
835       <code class="directive">RewriteRule</code> as follows:</p>
836
837       <pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1}"</pre>
838
839
840       <p>The meaning of the <em>MapTypeOptions</em> argument depends on
841       particular <em>MapType</em>. See the
842       <a href="../rewrite/rewritemap.html">Using RewriteMap</a> for
843       more information.</p>
844
845       <p>The following combinations for <em>MapType</em> and
846       <em>MapSource</em> can be used:</p>
847
848     <dl>
849
850     <dt>txt</dt>
851         <dd>A plain text file containing space-separated key-value
852         pairs, one per line. (<a href="../rewrite/rewritemap.html#txt">Details ...</a>)</dd>
853
854     <dt>rnd</dt>
855         <dd>Randomly selects an entry from a plain text file (<a href="../rewrite/rewritemap.html#rnd">Details ...</a>)</dd>
856
857     <dt>dbm</dt>
858         <dd>Looks up an entry in a dbm file containing name, value
859         pairs. Hash is constructed from a plain text file format using
860         the <code><a href="../programs/httxt2dbm.html">httxt2dbm</a></code>
861         utility.  (<a href="../rewrite/rewritemap.html#dbm">Details ...</a>)</dd>
862
863     <dt>int</dt>
864         <dd>One of the four available internal functions provided by
865         <code>RewriteMap</code>: toupper, tolower, escape or
866         unescape. (<a href="../rewrite/rewritemap.html#int">Details ...</a>)</dd>
867
868     <dt>prg</dt>
869         <dd>Calls an external program or script to process the
870         rewriting. (<a href="../rewrite/rewritemap.html#prg">Details ...</a>)</dd>
871
872     <dt>dbd or fastdbd</dt>
873         <dd>A SQL SELECT statement to be performed to look up the
874         rewrite target. (<a href="../rewrite/rewritemap.html#dbd">Details ...</a>)</dd>
875     </dl>
876
877     <p>Further details, and numerous examples, may be found in the <a href="../rewrite/rewritemap.html">RewriteMap HowTo</a></p>
878
879
880 </div>
881 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
882 <div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
883 <table class="directive">
884 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
885 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
886 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
887 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
888 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
889 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
890 </table>
891
892       <p>The <code class="directive">RewriteOptions</code> directive sets some
893       special options for the current per-server or per-directory
894       configuration. The <em>Option</em> string can currently
895       only be one of the following:</p>
896
897       <dl>
898       <dt><code>Inherit</code></dt>
899       <dd>
900
901       <p>This forces the current configuration to inherit the
902       configuration of the parent. In per-virtual-server context,
903       this means that the maps, conditions and rules of the main
904       server are inherited. In per-directory context this means
905       that conditions and rules of the parent directory's
906       <code>.htaccess</code> configuration or
907       <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code>
908       sections are inherited. The inherited rules are virtually copied
909       to the section where this directive is being used. If used in
910       combination with local rules, the inherited rules are copied behind
911       the local rules. The position of this directive - below or above
912       of local rules - has no influence on this behavior. If local
913       rules forced the rewriting to stop, the inherited rules won't
914       be processed.</p>
915
916       <div class="warning">
917       Rules inherited from the parent scope are applied
918       <strong>after</strong> rules specified in the child scope.
919       </div>
920       </dd>
921
922       <dt><code>InheritBefore</code></dt>
923       <dd>
924       <p> Like <code>Inherit</code> above, but the rules from the parent scope
925       are applied <strong>before</strong> rules specified in the child scope.<br />
926       Available in Apache HTTP Server 2.3.10 and later.</p>
927       </dd>
928
929       <dt><code>InheritDown</code></dt>
930       <dd>
931
932       <p>If this option is enabled, all child configurations will inherit
933       the configuration of the current configuration. It is equivalent to
934       specifying <code>RewriteOptions Inherit</code> in all child
935       configurations. See the <code>Inherit</code> option for more details
936       on how the parent-child relationships are handled.<br />
937       Available in Apache HTTP Server 2.4.8 and later.</p>
938       </dd>
939
940       <dt><code>InheritDownBefore</code></dt>
941       <dd>
942
943       <p>Like <code>InheritDown</code> above, but the rules from the current
944       scope are applied <strong>before</strong> rules specified in any child's
945       scope.<br />
946       Available in Apache HTTP Server 2.4.8 and later.</p>
947       </dd>
948
949       <dt><code>IgnoreInherit</code></dt>
950       <dd>
951
952       <p>This option forces the current and child configurations to ignore
953       all rules that would be inherited from a parent specifying
954       <code>InheritDown</code> or <code>InheritDownBefore</code>.<br />
955       Available in Apache HTTP Server 2.4.8 and later.</p>
956       </dd>
957
958       <dt><code>AllowNoSlash</code></dt>
959       <dd>
960       <p>By default, <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> will ignore URLs that map to a
961       directory on disk but lack a trailing slash, in the expectation that
962       the <code class="module"><a href="../mod/mod_dir.html">mod_dir</a></code> module will issue the client with a redirect to
963       the canonical URL with a trailing slash.</p>
964
965       <p>When the <code class="directive"><a href="../mod/mod_dir.html#directoryslash">DirectorySlash</a></code> directive
966       is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
967       that rewrite rules are no longer ignored. This option makes it possible to
968       apply rewrite rules within .htaccess files that match the directory without
969       a trailing slash, if so desired.<br />
970       Available in Apache HTTP Server 2.4.0 and later.</p>
971       </dd>
972
973       <dt><code>AllowAnyURI</code></dt>
974       <dd>
975
976       <p>When <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
977       is used in <code>VirtualHost</code> or server context with
978       version 2.2.22 or later of httpd, <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
979       will only process the rewrite rules if the request URI is a <a href="directive-dict.html#Syntax">URL-path</a>.  This avoids
980       some security issues where particular rules could allow
981       "surprising" pattern expansions (see <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3368">CVE-2011-3368</a>
982       and <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-4317">CVE-2011-4317</a>).
983       To lift the restriction on matching a URL-path, the
984       <code>AllowAnyURI</code> option can be enabled, and
985       <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> will apply the rule set to any
986       request URI string, regardless of whether that string matches
987       the URL-path grammar required by the HTTP specification.<br />
988       Available in Apache HTTP Server 2.4.3 and later.</p>
989
990       <div class="warning">
991       <h3>Security Warning</h3>
992
993       <p>Enabling this option will make the server vulnerable to
994       security issues if used with rewrite rules which are not
995       carefully authored.  It is <strong>strongly recommended</strong>
996       that this option is not used.  In particular, beware of input
997       strings containing the '<code>@</code>' character which could
998       change the interpretation of the transformed URI, as per the
999       above CVE names.</p>
1000       </div>
1001       </dd>
1002
1003       <dt><code>MergeBase</code></dt>
1004       <dd>
1005
1006       <p>With this option, the value of <code class="directive"><a href="#rewritebase">RewriteBase</a></code> is copied from where it's explicitly defined
1007       into any sub-directory or sub-location that doesn't define its own
1008       <code class="directive"><a href="#rewritebase">RewriteBase</a></code>. This was the
1009       default behavior in 2.4.0 through 2.4.3, and the flag to restore it is
1010       available Apache HTTP Server 2.4.4 and later.</p>
1011       </dd>
1012
1013       <dt><code>IgnoreContextInfo</code></dt>
1014       <dd>
1015
1016       <p>When a relative substitution is made
1017          in directory (htaccess) context and <code class="directive"><a href="#rewritebase">RewriteBase</a></code> has not been set, this module uses some
1018          extended URL and filesystem context information to change the
1019          relative substitution back into a URL. Modules such as
1020          <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>
1021          supply this extended context info.  Available in 2.4.16 and later.</p>
1022       </dd>
1023
1024       </dl>
1025
1026 </div>
1027 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
1028 <div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
1029 <table class="directive">
1030 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
1031 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteRule
1032       <em>Pattern</em> <em>Substitution</em> [<em>flags</em>]</code></td></tr>
1033 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
1034 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
1035 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
1036 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
1037 </table>
1038       <p>The <code class="directive">RewriteRule</code> directive is the real
1039       rewriting workhorse. The directive can occur more than once,
1040       with each instance defining a single rewrite rule. The
1041       order in which these rules are defined is important - this is the order
1042       in which they will be applied at run-time.</p>
1043
1044       <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
1045       a perl compatible <a id="regexp" name="regexp">regular
1046       expression</a>.  What this pattern is compared against varies depending
1047       on where the <code class="directive">RewriteRule</code> directive is defined. </p>
1048
1049 <div class="note"><h3><a id="what_is_matched" name="what_is_matched">What is matched?</a></h3>
1050
1051 <ul>
1052       <li><p>In <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> context,
1053       The <em>Pattern</em> will initially be matched against the part of the
1054       URL after the hostname and port, and before the query string (e.g. "/app1/index.html").
1055       This is the (%-decoded) <a href="directive-dict.html#Syntax">URL-path</a>.</p></li>
1056
1057       <li><p>In per-directory context (<code class="directive"><a href="../mod/core.html#directory">Directory</a></code> and .htaccess),
1058       the <em>Pattern</em> is matched against only a partial path, for example a request
1059       of "/app1/index.html" may result in comparison against "app1/index.html" 
1060       or "index.html" depending on where the <code class="directive">RewriteRule</code> is 
1061       defined.</p>
1062
1063       <p>The directory path where the rule is defined is stripped from the currently mapped
1064       filesystem path before comparison (up to and including a trailing slash). 
1065       The net result of this per-directory prefix stripping is that rules in
1066       this context only match against the portion of the currently mapped filesystem path 
1067       "below" where the rule is defined.</p>
1068
1069       <p>Directives such as <code class="directive">DocumentRoot</code> and <code class="directive">Alias</code>, or even the 
1070       result of previous <code class="directive">RewriteRule</code> substitutions, determine
1071       the currently mapped filesystem path.  
1072       </p>
1073       </li>
1074
1075       <li><p>If you wish to match against the hostname, port, or query string, use a
1076       <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the
1077       <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
1078       <code>%{QUERY_STRING}</code> variables respectively.</p></li>
1079 </ul>
1080 </div>
1081
1082 <div class="note"><h3>Per-directory Rewrites</h3>
1083 <ul>
1084 <li>The rewrite engine may be used in <a href="../howto/htaccess.html">.htaccess</a> files and in <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> sections, with some additional
1085 complexity.</li>
1086
1087 <li>To enable the rewrite engine in this context, you need to set
1088 "<code>RewriteEngine On</code>" <strong>and</strong>
1089 "<code>Options FollowSymLinks</code>" must be enabled. If your
1090 administrator has disabled override of <code>FollowSymLinks</code> for
1091 a user's directory, then you cannot use the rewrite engine. This
1092 restriction is required for security reasons.</li>
1093
1094 <li>See the <code class="directive"><a href="#rewritebase">RewriteBase</a></code>
1095 directive for more information regarding what prefix will be added back to
1096 relative substitutions.</li>
1097
1098 <li> If you wish to match against the full URL-path in a per-directory
1099 (htaccess) RewriteRule, use the <code>%{REQUEST_URI}</code> variable in
1100 a <code class="directive"><a href="#rewritecond">RewriteCond</a></code>.</li>
1101
1102 <li>The removed prefix always ends with a slash, meaning the matching occurs against a string which
1103 <em>never</em> has a leading slash.  Therefore, a <em>Pattern</em> with <code>^/</code> never
1104 matches in per-directory context.</li>
1105
1106 <li>Although rewrite rules are syntactically permitted in <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code> and <code class="directive"><a href="../mod/core.html#files">&lt;Files&gt;</a></code> sections
1107 (including their regular expression counterparts), this
1108 should never be necessary and is unsupported. A likely feature
1109 to break in these contexts is relative substitutions.</li>
1110 </ul>
1111 </div>
1112
1113       <p>For some hints on <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular
1114       expressions</a>, see
1115       the <a href="../rewrite/intro.html#regex">mod_rewrite
1116       Introduction</a>.</p>
1117
1118       <p>In mod_rewrite, the NOT character
1119       ('<code>!</code>') is also available as a possible pattern
1120       prefix. This enables you to negate a pattern; to say, for instance:
1121       ``<em>if the current URL does <strong>NOT</strong> match this
1122       pattern</em>''. This can be used for exceptional cases, where
1123       it is easier to match the negative pattern, or as a last
1124       default rule.</p>
1125
1126 <div class="note"><h3>Note</h3>
1127 When using the NOT character to negate a pattern, you cannot include
1128 grouped wildcard parts in that pattern. This is because, when the
1129 pattern does NOT match (ie, the negation matches), there are no
1130 contents for the groups. Thus, if negated patterns are used, you
1131 cannot use <code>$N</code> in the substitution string!
1132 </div>
1133
1134       <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
1135       rewrite rule is the string that replaces the original URL-path that
1136       was matched by <em>Pattern</em>.  The <em>Substitution</em> may
1137       be a:</p>
1138
1139       <dl>
1140
1141         <dt>file-system path</dt>
1142
1143         <dd>Designates the location on the file-system of the resource
1144         to be delivered to the client.  Substitutions are only
1145         treated as a file-system path when the rule is configured in
1146         server (virtualhost) context and the first component of the
1147         path in the substitution exists in the file-system</dd>
1148
1149         <dt>URL-path</dt>
1150
1151         <dd>A <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
1152         resource to be served. Note that <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
1153         tries to guess whether you have specified a file-system path
1154         or a URL-path by checking to see if the first segment of the
1155         path exists at the root of the file-system. For example, if
1156         you specify a <em>Substitution</em> string of
1157         <code>/www/file.html</code>, then this will be treated as a
1158         URL-path <em>unless</em> a directory named <code>www</code>
1159         exists at the root or your file-system (or, in the case of
1160         using rewrites in a <code>.htaccess</code> file, relative to
1161         your document root), in which case it will
1162         be treated as a file-system path. If you wish other
1163         URL-mapping directives (such as <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>) to be applied to the
1164         resulting URL-path, use the <code>[PT]</code> flag as
1165         described below.</dd>
1166
1167         <dt>Absolute URL</dt>
1168
1169         <dd>If an absolute URL is specified,
1170         <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> checks to see whether the
1171         hostname matches the current host. If it does, the scheme and
1172         hostname are stripped out and the resulting path is treated as
1173         a URL-path. Otherwise, an external redirect is performed for
1174         the given URL. To force an external redirect back to the
1175         current host, see the <code>[R]</code> flag below.</dd>
1176
1177         <dt><code>-</code> (dash)</dt>
1178
1179         <dd>A dash indicates that no substitution should be performed
1180         (the existing path is passed through untouched). This is used
1181         when a flag (see below) needs to be applied without changing
1182         the path.</dd>
1183
1184       </dl>
1185
1186       <p>In addition to plain text, the <em>Substitution</em> string can include</p>
1187
1188       <ol>
1189         <li>back-references (<code>$N</code>) to the RewriteRule
1190         pattern</li>
1191
1192         <li>back-references (<code>%N</code>) to the last matched
1193         RewriteCond pattern</li>
1194
1195         <li>server-variables as in rule condition test-strings
1196         (<code>%{VARNAME}</code>)</li>
1197
1198         <li><a href="#mapfunc">mapping-function</a> calls
1199         (<code>${mapname:key|default}</code>)</li>
1200       </ol>
1201
1202       <p>Back-references are identifiers of the form
1203       <code>$</code><strong>N</strong>
1204       (<strong>N</strong>=0..9), which will be replaced
1205       by the contents of the <strong>N</strong>th group of the
1206       matched <em>Pattern</em>. The server-variables are the same
1207       as for the <em>TestString</em> of a
1208       <code class="directive"><a href="#rewritecond">RewriteCond</a></code>
1209       directive. The mapping-functions come from the
1210       <code class="directive"><a href="#rewritemap">RewriteMap</a></code>
1211       directive and are explained there.
1212       These three types of variables are expanded in the order above.</p>
1213
1214       <p>Rewrite rules are applied to the results of previous rewrite
1215       rules, in the order in which they are defined
1216       in the config file. The URL-path or file-system path (see <a href="#what_is_matched">"What is matched?"</a>, above) is <strong>completely
1217       replaced</strong> by the <em>Substitution</em> and the
1218       rewriting process continues until all rules have been applied,
1219       or it is explicitly terminated by an
1220       <a href="../rewrite/flags.html#flag_l"><code><strong>L</strong></code> flag</a>,
1221       or other flag which implies immediate termination, such as
1222       <code><strong>END</strong></code> or
1223       <code><strong>F</strong></code>.</p>
1224
1225      <div class="note"><h3>Modifying the Query String</h3>
1226       <p>By default, the query string is passed through unchanged. You
1227       can, however, create URLs in the substitution string containing
1228       a query string part. Simply use a question mark inside the
1229       substitution string to indicate that the following text should
1230       be re-injected into the query string. When you want to erase an
1231       existing query string, end the substitution string with just a
1232       question mark. To combine new and old query strings, use the
1233       <code>[QSA]</code> flag.</p>
1234      </div>
1235
1236       <p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
1237       appending <strong><code>[</code><em>flags</em><code>]</code></strong>
1238       as the third argument to the <code class="directive">RewriteRule</code>
1239       directive. <em>Flags</em> is a comma-separated list, surround by square
1240       brackets, of any of the flags in the following table. More
1241       details, and examples, for each flag, are available in the <a href="../rewrite/flags.html">Rewrite Flags document</a>.</p>
1242
1243     <table class="bordered"><tr class="header"><th>Flag and syntax</th>
1244         <th>Function</th>
1245     </tr>
1246 <tr>
1247         <td>B</td>
1248         <td>Escape non-alphanumeric characters in backreferences <em>before</em>
1249         applying the transformation. <em><a href="../rewrite/flags.html#flag_b">details ...</a></em></td>
1250     </tr>
1251 <tr class="odd">
1252         <td>backrefnoplus|BNP</td>
1253         <td>If backreferences are being escaped, spaces should be escaped to
1254         %20 instead of +. Useful when the backreference will be used in the
1255         path component rather than the query string.<em><a href="../rewrite/flags.html#flag_bnp">details ...</a></em></td>
1256     </tr>
1257 <tr>
1258         <td>chain|C</td>
1259         <td>Rule is chained to the following rule. If the rule fails,
1260         the rule(s) chained to it will be skipped. <em><a href="../rewrite/flags.html#flag_c">details ...</a></em></td>
1261     </tr>
1262 <tr class="odd">
1263         <td>cookie|CO=<em>NAME</em>:<em>VAL</em></td>
1264         <td>Sets a cookie in the client browser. Full syntax is:
1265         CO=<em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>[:<em>secure</em>[:<em>httponly</em>]]]] <em><a href="../rewrite/flags.html#flag_co">details ...</a></em>
1266         </td>
1267     </tr>
1268 <tr>
1269         <td>discardpath|DPI</td>
1270         <td>Causes the PATH_INFO portion of the rewritten URI to be
1271         discarded. <em><a href="../rewrite/flags.html#flag_dpi">details
1272         ...</a></em></td>
1273     </tr>
1274 <tr class="odd">
1275         <td>END</td>
1276         <td>Stop the rewriting process immediately and don't apply any
1277         more rules. Also prevents further execution of rewrite rules
1278         in per-directory and .htaccess context. (Available in 2.3.9 and later)
1279         <em><a href="../rewrite/flags.html#flag_end">details ...</a></em></td>
1280     </tr>
1281 <tr>
1282         <td>env|E=[!]<em>VAR</em>[:<em>VAL</em>]</td>
1283         <td>Causes an environment variable <em>VAR</em> to be set (to the
1284         value <em>VAL</em> if provided). The form !<em>VAR</em> causes
1285         the environment variable <em>VAR</em> to be unset.
1286         <em><a href="../rewrite/flags.html#flag_e">details ...</a></em></td>
1287     </tr>
1288 <tr class="odd">
1289         <td>forbidden|F</td>
1290         <td>Returns a 403 FORBIDDEN response to the client browser.
1291         <em><a href="../rewrite/flags.html#flag_f">details ...</a></em></td>
1292     </tr>
1293 <tr>
1294         <td>gone|G</td>
1295         <td>Returns a 410 GONE response to the client browser. <em><a href="../rewrite/flags.html#flag_g">details ...</a></em></td>
1296     </tr>
1297 <tr class="odd">
1298         <td>Handler|H=<em>Content-handler</em></td>
1299         <td>Causes the resulting URI to be sent to the specified
1300         <em>Content-handler</em> for processing. <em><a href="../rewrite/flags.html#flag_h">details ...</a></em></td>
1301     </tr>
1302 <tr>
1303         <td>last|L</td>
1304         <td>Stop the rewriting process immediately and don't apply any
1305         more rules. Especially note caveats for per-directory and
1306         .htaccess context (see also the END flag). <em><a href="../rewrite/flags.html#flag_l">details ...</a></em></td>
1307     </tr>
1308 <tr class="odd">
1309         <td>next|N</td>
1310         <td>Re-run the rewriting process, starting again with the first
1311         rule, using the result of the ruleset so far as a starting
1312         point. <em><a href="../rewrite/flags.html#flag_n">details
1313         ...</a></em></td>
1314     </tr>
1315 <tr>
1316         <td>nocase|NC</td>
1317         <td>Makes the pattern comparison case-insensitive.
1318         <em><a href="../rewrite/flags.html#flag_nc">details ...</a></em></td>
1319     </tr>
1320 <tr class="odd">
1321         <td>noescape|NE</td>
1322         <td>Prevent mod_rewrite from applying hexcode escaping of
1323         special characters in the result of the rewrite. <em><a href="../rewrite/flags.html#flag_ne">details ...</a></em></td>
1324     </tr>
1325 <tr>
1326         <td>nosubreq|NS</td>
1327         <td>Causes a rule to be skipped if the current request is an
1328         internal sub-request. <em><a href="../rewrite/flags.html#flag_ns">details ...</a></em></td>
1329     </tr>
1330 <tr class="odd">
1331         <td>proxy|P</td>
1332         <td>Force the substitution URL to be internally sent as a proxy
1333         request. <em><a href="../rewrite/flags.html#flag_p">details
1334         ...</a></em></td>
1335     </tr>
1336 <tr>
1337         <td>passthrough|PT</td>
1338         <td>Forces the resulting URI to be passed back to the URL
1339         mapping engine for processing of other URI-to-filename
1340         translators, such as <code>Alias</code> or
1341         <code>Redirect</code>. <em><a href="../rewrite/flags.html#flag_pt">details ...</a></em></td>
1342     </tr>
1343 <tr class="odd">
1344         <td>qsappend|QSA</td>
1345         <td>Appends any query string from the original request URL to
1346         any query string created in the rewrite target.<em><a href="../rewrite/flags.html#flag_qsa">details ...</a></em></td>
1347     </tr>
1348 <tr>
1349         <td>qsdiscard|QSD</td>
1350         <td>Discard any query string attached to the incoming URI.
1351         <em><a href="../rewrite/flags.html#flag_qsd">details
1352         ...</a></em></td>
1353     </tr>
1354 <tr class="odd">
1355         <td>qslast|QSL</td>
1356         <td>Interpret the last (right-most) question mark as the query string
1357             delimeter, instead of the first (left-most) as normally used.  
1358             Available in 2.4.19 and later.
1359         <em><a href="../rewrite/flags.html#flag_qsl">details
1360         ...</a></em></td>
1361     </tr>
1362 <tr>
1363         <td>redirect|R[=<em>code</em>]</td>
1364         <td>Forces an external redirect, optionally with the specified
1365         HTTP status code. <em><a href="../rewrite/flags.html#flag_r">details ...</a></em>
1366         </td>
1367     </tr>
1368 <tr class="odd">
1369         <td>skip|S=<em>num</em></td>
1370         <td>Tells the rewriting engine to skip the next <em>num</em>
1371         rules if the current rule matches. <em><a href="../rewrite/flags.html#flag_s">details ...</a></em></td>
1372     </tr>
1373 <tr>
1374         <td>type|T=<em>MIME-type</em></td>
1375         <td>Force the <a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file
1376         to be the specified type. <em><a href="../rewrite/flags.html#flag_t">details ...</a></em></td>
1377     </tr>
1378 </table>
1379
1380 <div class="note"><h3>Home directory expansion</h3>
1381 <p> When the substitution string begins with a string
1382 resembling "/~user" (via explicit text or backreferences), mod_rewrite performs
1383 home directory expansion independent of the presence or configuration
1384 of <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code>.</p>
1385
1386 <p> This expansion does not occur when the <em>PT</em>
1387 flag is used on the <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
1388 directive.</p>
1389 </div>
1390
1391
1392      <p>Here are all possible substitution combinations and their
1393       meanings:</p>
1394
1395       <p><strong>Inside per-server configuration
1396       (<code>httpd.conf</code>)<br />
1397        for request ``<code>GET
1398       /somepath/pathinfo</code>'':</strong><br />
1399       </p>
1400
1401 <table class="bordered"><tr class="header">
1402 <th>Given Rule</th>
1403 <th>Resulting Substitution</th>
1404 </tr>
1405 <tr>
1406 <td>^/somepath(.*) otherpath$1</td>
1407 <td>invalid, not supported</td>
1408 </tr>
1409 <tr class="odd">
1410 <td>^/somepath(.*) otherpath$1  [R]</td>
1411 <td>invalid, not supported</td>
1412 </tr>
1413 <tr>
1414 <td>^/somepath(.*) otherpath$1  [P]</td>
1415 <td>invalid, not supported</td>
1416 </tr>
1417 <tr class="odd">
1418 <td>^/somepath(.*) /otherpath$1</td>
1419 <td>/otherpath/pathinfo</td>
1420 </tr>
1421 <tr>
1422 <td>^/somepath(.*) /otherpath$1 [R]</td>
1423 <td>http://thishost/otherpath/pathinfo via external redirection</td>
1424 </tr>
1425 <tr class="odd">
1426 <td>^/somepath(.*) /otherpath$1 [P]</td>
1427 <td>doesn't make sense, not supported</td>
1428 </tr>
1429 <tr>
1430 <td>^/somepath(.*) http://thishost/otherpath$1</td>
1431 <td>/otherpath/pathinfo</td>
1432 </tr>
1433 <tr class="odd">
1434 <td>^/somepath(.*) http://thishost/otherpath$1 [R]</td>
1435 <td>http://thishost/otherpath/pathinfo via external redirection</td>
1436 </tr>
1437 <tr>
1438 <td>^/somepath(.*) http://thishost/otherpath$1 [P]</td>
1439 <td>doesn't make sense, not supported</td>
1440 </tr>
1441 <tr class="odd">
1442 <td>^/somepath(.*) http://otherhost/otherpath$1</td>
1443 <td>http://otherhost/otherpath/pathinfo via external redirection</td>
1444 </tr>
1445 <tr>
1446 <td>^/somepath(.*) http://otherhost/otherpath$1 [R]</td>
1447 <td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
1448 </tr>
1449 <tr class="odd">
1450 <td>^/somepath(.*) http://otherhost/otherpath$1 [P]</td>
1451 <td>http://otherhost/otherpath/pathinfo via internal proxy</td>
1452 </tr>
1453 </table>
1454
1455       <p><strong>Inside per-directory configuration for
1456       <code>/somepath</code><br />
1457        (<code>/physical/path/to/somepath/.htaccess</code>, with
1458       <code>RewriteBase "/somepath"</code>)<br />
1459        for request ``<code>GET
1460       /somepath/localpath/pathinfo</code>'':</strong><br />
1461      </p>
1462
1463 <table class="bordered"><tr class="header">
1464 <th>Given Rule</th>
1465 <th>Resulting Substitution</th>
1466 </tr>
1467 <tr>
1468 <td>^localpath(.*) otherpath$1</td>
1469 <td>/somepath/otherpath/pathinfo</td>
1470 </tr>
1471 <tr class="odd">
1472 <td>^localpath(.*) otherpath$1  [R]</td>
1473 <td>http://thishost/somepath/otherpath/pathinfo via external
1474 redirection</td>
1475 </tr>
1476 <tr>
1477 <td>^localpath(.*) otherpath$1  [P]</td>
1478 <td>doesn't make sense, not supported</td>
1479 </tr>
1480 <tr class="odd">
1481 <td>^localpath(.*) /otherpath$1</td>
1482 <td>/otherpath/pathinfo</td>
1483 </tr>
1484 <tr>
1485 <td>^localpath(.*) /otherpath$1 [R]</td>
1486 <td>http://thishost/otherpath/pathinfo via external redirection</td>
1487 </tr>
1488 <tr class="odd">
1489 <td>^localpath(.*) /otherpath$1 [P]</td>
1490 <td>doesn't make sense, not supported</td>
1491 </tr>
1492 <tr>
1493 <td>^localpath(.*) http://thishost/otherpath$1</td>
1494 <td>/otherpath/pathinfo</td>
1495 </tr>
1496 <tr class="odd">
1497 <td>^localpath(.*) http://thishost/otherpath$1 [R]</td>
1498 <td>http://thishost/otherpath/pathinfo via external redirection</td>
1499 </tr>
1500 <tr>
1501 <td>^localpath(.*) http://thishost/otherpath$1 [P]</td>
1502 <td>doesn't make sense, not supported</td>
1503 </tr>
1504 <tr class="odd">
1505 <td>^localpath(.*) http://otherhost/otherpath$1</td>
1506 <td>http://otherhost/otherpath/pathinfo via external redirection</td>
1507 </tr>
1508 <tr>
1509 <td>^localpath(.*) http://otherhost/otherpath$1 [R]</td>
1510 <td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
1511 </tr>
1512 <tr class="odd">
1513 <td>^localpath(.*) http://otherhost/otherpath$1 [P]</td>
1514 <td>http://otherhost/otherpath/pathinfo via internal proxy</td>
1515 </tr>
1516 </table>
1517
1518   
1519 </div>
1520 </div>
1521 <div class="bottomlang">
1522 <p><span>Available Languages: </span><a href="../en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
1523 <a href="../fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
1524 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
1525 <script type="text/javascript"><!--//--><![CDATA[//><!--
1526 var comments_shortname = 'httpd';
1527 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_rewrite.html';
1528 (function(w, d) {
1529     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
1530         d.write('<div id="comments_thread"><\/div>');
1531         var s = d.createElement('script');
1532         s.type = 'text/javascript';
1533         s.async = true;
1534         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
1535         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
1536     }
1537     else {
1538         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
1539     }
1540 })(window, document);
1541 //--><!]]></script></div><div id="footer">
1542 <p class="apache">Copyright 2016 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>
1543 <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[//><!--
1544 if (typeof(prettyPrint) !== 'undefined') {
1545     prettyPrint();
1546 }
1547 //--><!]]></script>
1548 </body></html>