mod_rewrite.html.en revision 81785f72c9d133aef57ad6b02f248345d90239aa
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder This file is generated from xml source: DO NOT EDIT
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu<title>mod_rewrite - Apache HTTP Server</title>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<link href="/images/favicon.ico" rel="shortcut icon" /></head>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder<p class="apache">Apache HTTP Server Version 2.3</p>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<img alt="" src="/images/feather.gif" /></div>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.3</a> > <a href="./">Modules</a></div>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<div id="preamble"><h1>Apache Module mod_rewrite</h1>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English"> en </a> |
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a></p>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>rewrite_module</td></tr>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_rewrite.c</td></tr>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 1.3 and later</td></tr></table>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p>This module uses a rule-based rewriting engine (based on a
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder regular-expression parser) to rewrite requested URLs on the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder fly. It supports an unlimited number of rules and an
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder unlimited number of attached rule conditions for each rule, to
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder provide a really flexible and powerful URL manipulation
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder mechanism. The URL manipulations can depend on various tests,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder of server variables, environment variables, HTTP
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder headers, or time stamps. Even external database lookups in
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder various formats can be used to achieve highly granular URL
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p>This module operates on the full URLs (including the
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder path-info part) both in per-server context
c56a356d3fcc5e123efa790aab320781d94df3c7Jonathan von Schroeder (<code>httpd.conf</code>) and per-directory context
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder (<code>.htaccess</code>) and can generate query-string
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder parts on result. The rewritten result can lead to internal
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder sub-processing, external request redirection or even to an
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder internal proxy throughput.</p>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p>Further details, discussion, and examples, are provided in the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<div id="quickview"><h3 class="directives">Directives</h3>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewritelock">RewriteLock</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewritelog">RewriteLog</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewriteloglevel">RewriteLogLevel</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#quoting">Quoting Special Characters</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#EnvVar">Environment Variables</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#vhosts">Rewriting in Virtual Hosts</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><img alt="" src="/images/down.gif" /> <a href="#Solutions">Practical Solutions</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<li><a href="#rewriteflags">Rewrite Flags</a></li>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<h2><a name="quoting" id="quoting">Quoting Special Characters</a></h2>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p>As of Apache 1.3.20, special characters in
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <em>TestString</em> and <em>Substitution</em> strings can be
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder escaped (that is, treated as normal characters without their
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder usual special meaning) by prefixing them with a slash ('\')
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder character. In other words, you can include an actual
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder dollar-sign character in a <em>Substitution</em> string by
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder using '<code>\$</code>'; this keeps mod_rewrite from trying
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder to treat it as a backreference.</p>
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder<h2><a name="EnvVar" id="EnvVar">Environment Variables</a></h2>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p>This module keeps track of two additional (non-standard)
a65c6747c9acbbebc93baba7bae94d2e3d8cdafbTill Mossakowski CGI/SSI environment variables named <code>SCRIPT_URL</code>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder and <code>SCRIPT_URI</code>. These contain the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <em>logical</em> Web-view to the current resource, while the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder standard CGI/SSI variables <code>SCRIPT_NAME</code> and
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <code>SCRIPT_FILENAME</code> contain the <em>physical</em>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder System-view. </p>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p>Notice: These variables hold the URI/URL <em>as they were
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder initially requested</em>, that is, <em>before</em> any
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder rewriting. This is important to note because the rewriting process is
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder primarily used to rewrite logical URLs to physical
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder pathnames.<br />
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder These variables are set in per-server context, which means
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder that they are available in per-directory context only, if
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <code class="directive">RewriteEngine</code> is set to <code>on</code> in
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder per-server context.</p>
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder<div class="example"><h3>Example</h3><pre>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von SchroederSCRIPT_NAME=/sw/lib/w3s/tree/global/u/rse/.www/index.html
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von SchroederSCRIPT_FILENAME=/u/rse/.www/index.html
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von SchroederSCRIPT_URI=http://en1.engelschall.com/u/rse/
e24ad3f655daa60ddabe690e4b11de3187996c16cmaeder</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<h2><a name="vhosts" id="vhosts">Rewriting in Virtual Hosts</a></h2>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder <p>By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> configuration
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder settings from the main server context are not inherited by
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder virtual hosts. To make the main server settings apply to virtual
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder hosts, you must place the following directives in each <code class="directive"><a href="/mod/core.html#virtualhost"><VirtualHost></a></code> section:</p>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder RewriteEngine On<br />
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder RewriteOptions Inherit
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder<h2><a name="Solutions" id="Solutions">Practical Solutions</a></h2>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p>For numerous examples of common, and not-so-common, uses for
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder mod_rewrite, see the <a href="/rewrite/rewrite_guide.html">Rewrite
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder Guide</a>, and the <a href="/rewrite/rewrite_guide_advanced.html">Advanced Rewrite
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder<div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>See usage for information.</code></td></tr>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
8c7aa750542dcadb94b971be712564a9a8f1d189Christian Maeder<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder <p>The <code class="directive">RewriteBase</code> directive explicitly
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder sets the base URL for per-directory rewrites. As you will see
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder below, <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder can be used in per-directory config files
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder (<code>.htaccess</code>). In such a case, it will act locally,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder stripping the local directory prefix before processing, and applying
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder rewrite rules only to the remainder. When processing is complete, the
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder prefix is automatically added back to the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder path. The default setting is; <code class="directive">RewriteBase</code> <em>physical-directory-path</em></p>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder <p>When a substitution occurs for a new URL, this module has
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder to re-inject the URL into the server processing. To be able
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder to do this it needs to know what the corresponding URL-prefix
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder or URL-base is. By default this prefix is the corresponding
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder filepath itself. <strong>However, for most websites, URLs are NOT
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder directly related to physical filename paths, so this
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder assumption will often be wrong!</strong> Therefore, you can
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder use the <code>RewriteBase</code> directive to specify the
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder correct URL-prefix.</p>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder<div class="note"> If your webserver's URLs are <strong>not</strong> directly
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroederrelated to physical file paths, you will need to use
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder<code class="directive">RewriteBase</code> in every <code>.htaccess</code>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederfile where you want to use <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder <p> For example, assume the following per-directory config file:</p>
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder# /abc/def/.htaccess -- per-dir config file for directory /abc/def
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder# Remember: /abc/def is the physical path of /xyz, <em>i.e.</em>, the server
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder# has a 'Alias /xyz /abc/def' directive <em>e.g.</em>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von SchroederRewriteEngine On
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder# let the server know that we were reached via /xyz and not
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder# via the physical path prefix /abc/def
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von SchroederRewriteBase /xyz
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder# now the rewriting rules
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von SchroederRewriteRule ^oldstuff\.html$ newstuff.html
<div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
the current state of the URI matches its pattern, <strong>and</strong> if these conditions are met.</p>
<code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
RewriteRule ...some special stuff for any of these hosts...
RewriteRule ^/$ /homepage.max.html [L]
RewriteRule ^/$ /homepage.min.html [L]
RewriteRule ^/$ /homepage.std.html [L]
<div class="directive-section"><h2><a name="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives!</p>
<div class="directive-section"><h2><a name="RewriteLock" id="RewriteLock">RewriteLock</a> <a name="rewritelock" id="rewritelock">Directive</a></h2>
<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>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLock <em>file-path</em></code></td></tr>
lockfile which mod_rewrite needs to communicate with <code class="directive"><a href="#rewritemap">RewriteMap</a></code>
<div class="directive-section"><h2><a name="RewriteLog" id="RewriteLog">RewriteLog</a> <a name="rewritelog" id="rewritelog">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the file used for logging rewrite engine
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLog <em>file-path</em></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<div class="directive-section"><h2><a name="RewriteLogLevel" id="RewriteLogLevel">RewriteLogLevel</a> <a name="rewriteloglevel" id="rewriteloglevel">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the verbosity of the log file used by the rewrite
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLogLevel <em>Level</em></code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteLogLevel 0</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The choice of different dbm types is available in
## map.txt -- rewriting map
Ralf.S.Engelschall rse # Bastard Operator From Hell
Mr.Joe.Average joe # Mr. Average
## map.txt -- rewriting map
<p>To create a dbm file from a source text file, use the <a href="/programs/httxt2dbm.html">httxt2dbm</a> utility.</p>
# ...put here any transformations or lookups...
<p>This uses <code class="module"><a href="/mod/mod_dbd.html">mod_dbd</a></code> to implement a rewritemap
<div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td><code>MaxRedirects</code> is no longer available in version 2.1 and
<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<p>For some hints on <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular
<dd>A <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
resource to be served. Note that <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
URL-mapping directives (such as <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>) to be applied to the
<code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> checks to see whether the
<p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
RewriteRule ^(/.*)$ /index.php?show=$1
<dt>'<code>cookie|CO=</code><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>[:<em>secure</em>[:<em>httponly</em>]]]]'
in Apache when <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> tries to find out
<p>Note: <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code> must be enabled in order
Force the <a class="glossarylink" href="/glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file to be
<p>The rewrite engine may be used in <a href="/howto/htaccess.html">.htaccess</a> files. To enable the
<p>The rewrite engine may also be used in <code class="directive"><a href="/mod/core.html#directory"><Directory></a></code> sections with the same
virtual host context, rather than in a <code class="directive"><a href="/mod/core.html#directory"><Directory></a></code> section.</p>
<p>Although rewrite rules are syntactically permitted in <code class="directive"><a href="/mod/core.html#location"><Location></a></code> and <code class="directive"><a href="/mod/core.html#files"><Files></a></code> sections, this
^/somepath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
^/somepath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
^localpath(.*) otherpath$1 [R] http://thishost/somepath/otherpath/pathinfo
^localpath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
^localpath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English"> en </a> |
<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a></p>
<p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>