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