]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Rebuild the most recent work on the rewrite guide
authorRich Bowen <rbowen@apache.org>
Fri, 15 May 2026 18:17:30 +0000 (18:17 +0000)
committerRich Bowen <rbowen@apache.org>
Fri, 15 May 2026 18:17:30 +0000 (18:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1934235 13f79535-47bb-0310-9956-ffa450edef68

59 files changed:
docs/manual/rewrite/avoid.html.en.utf8
docs/manual/rewrite/avoid.xml.de
docs/manual/rewrite/avoid.xml.es
docs/manual/rewrite/avoid.xml.fr
docs/manual/rewrite/avoid.xml.ja
docs/manual/rewrite/avoid.xml.ko
docs/manual/rewrite/avoid.xml.tr
docs/manual/rewrite/avoid.xml.zh-cn
docs/manual/rewrite/flags.html.en.utf8
docs/manual/rewrite/flags.xml.de
docs/manual/rewrite/flags.xml.es
docs/manual/rewrite/flags.xml.fr
docs/manual/rewrite/flags.xml.ja
docs/manual/rewrite/flags.xml.ko
docs/manual/rewrite/flags.xml.tr
docs/manual/rewrite/flags.xml.zh-cn
docs/manual/rewrite/htaccess.html.en.utf8
docs/manual/rewrite/htaccess.xml.de
docs/manual/rewrite/htaccess.xml.es
docs/manual/rewrite/htaccess.xml.fr
docs/manual/rewrite/htaccess.xml.ja
docs/manual/rewrite/htaccess.xml.ko
docs/manual/rewrite/htaccess.xml.tr
docs/manual/rewrite/htaccess.xml.zh-cn
docs/manual/rewrite/index.html.fr.utf8
docs/manual/rewrite/index.xml.meta
docs/manual/rewrite/intro.html.en.utf8
docs/manual/rewrite/intro.xml.de
docs/manual/rewrite/intro.xml.es
docs/manual/rewrite/intro.xml.fr
docs/manual/rewrite/intro.xml.ja
docs/manual/rewrite/intro.xml.ko
docs/manual/rewrite/intro.xml.tr
docs/manual/rewrite/intro.xml.zh-cn
docs/manual/rewrite/remapping.html.en.utf8
docs/manual/rewrite/remapping.xml.de
docs/manual/rewrite/remapping.xml.es
docs/manual/rewrite/remapping.xml.fr
docs/manual/rewrite/remapping.xml.ja
docs/manual/rewrite/remapping.xml.ko
docs/manual/rewrite/remapping.xml.tr
docs/manual/rewrite/remapping.xml.zh-cn
docs/manual/rewrite/rewritemap.html.en.utf8
docs/manual/rewrite/rewritemap.xml.de
docs/manual/rewrite/rewritemap.xml.es
docs/manual/rewrite/rewritemap.xml.fr
docs/manual/rewrite/rewritemap.xml.ja
docs/manual/rewrite/rewritemap.xml.ko
docs/manual/rewrite/rewritemap.xml.tr
docs/manual/rewrite/rewritemap.xml.zh-cn
docs/manual/rewrite/tech.html.en.utf8
docs/manual/rewrite/tech.html.fr.utf8
docs/manual/rewrite/tech.xml.de
docs/manual/rewrite/tech.xml.es
docs/manual/rewrite/tech.xml.fr
docs/manual/rewrite/tech.xml.ja
docs/manual/rewrite/tech.xml.ko
docs/manual/rewrite/tech.xml.tr
docs/manual/rewrite/tech.xml.zh-cn

index ee0d528f4f981779014b71263936334c54d6e1cd..7befac3e0562af6c7456c43992c6f22e7ec50eaa 100644 (file)
@@ -114,11 +114,22 @@ the recommended configuration and the
 <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> alternative for <code>.htaccess</code>
 use.</p>
 
+    <div class="note"><h3>Processing order</h3>
+    <p>If you do mix <code class="directive"><a href="../mod/mod_alias.html#redirect">Redirect</a></code>
+    and <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> in the
+    same context, be aware that their execution order depends on where
+    they appear. In server/virtual-host context,
+    <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> runs first; in per-directory context
+    (<code>.htaccess</code>), <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> runs first. See
+    <a href="tech.html#order">Module Processing Order</a> for
+    details.</p>
+    </div>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="alias" id="alias">URL Aliasing</a> <a title="Permanent link" href="#alias" class="permalink">&para;</a></h2>
 <p>The <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> directive
-provides mapping from a URI to a directory - usually a directory outside
+provides mapping from a URL-path to a directory - usually a directory outside
 of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. Although it
 is possible to perform this mapping with <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>,
 <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> is the preferred method, for
index c9acc8cccf944e842bc34cf9efdc2a83c86c75a0..b2b261cf08ca4ad2fe515019461e055bcaa8300e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 1933071:1934122 (outdated) -->
+<!-- English Revision: 1933071:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 1bed561760a973de56cc4618ae05c1609d076db7..1f1ccadf67228690c6f491eb4d9d1538f6989683 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.es.xsl"?>
-<!-- English Revision: 1933071:1934122 (outdated) -->
+<!-- English Revision: 1933071:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 7a02fea7e40142cd2f1da94348dbd1991980a291..995159d0d25d549be31c5c640d389ed93077ca09 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1933071:1934122 (outdated) -->
+<!-- English Revision: 1933071:1934233 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index c651a7e8047797cfccd8d2044994d065aff7a3dd..0cf8d2d857e581dfa52f4e040b3c4f35859d6cbf 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1933071:1934122 (outdated) -->
+<!-- English Revision: 1933071:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 055bd902218c7135eaa23fb33989096b7346cdc8..31b12bfeb73a03a2fd579eb7f6486e703ea1cb14 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='EUC-KR' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 1933071:1934122 (outdated) -->
+<!-- English Revision: 1933071:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 6fcb250e25d080d19e3293793a56a461c98516d7..28e38d296a6d7f6042552e304198999cd07d7e77 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1933071:1934122 (outdated) -->
+<!-- English Revision: 1933071:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index c97ea251b894bceec3b2333c00e7ecf62a5c123f..fc3fb0356d34cba384f3e999288b127ed61759c5 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.zh-cn.xsl"?>
-<!-- English Revision: 1933071:1934122 (outdated) -->
+<!-- English Revision: 1933071:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index fb165cf8efa1799145d0ec4f5c6cd4f02a45d675..23ffc5577146adcd5386d3d827921ffb7486d746 100644 (file)
@@ -145,6 +145,9 @@ RewriteRule "^search/(.*)$" "/search.php?term=$1" "[B= ?]"</pre>
 
 <p>To limit the characters escaped this way, see <a href="#flag_bne">#flag_bne</a>
         and <a href="#flag_bctls">#flag_bctls</a></p>
+
+<p>See <a href="tech.html#encoding">URL Encoding and Decoding</a> for
+a full explanation of how Apache decodes URIs before pattern matching.</p>
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_bnp" id="flag_bnp">BNP|backrefnoplus (don't escape space to +)</a> <a title="Permanent link" href="#flag_bnp" class="permalink">&para;</a></h2>
@@ -159,6 +162,9 @@ RewriteRule "^search/(.*)$" "/search.php/$1" "[B,BNP]"</pre>
 
 
 <p>This flag is available in version 2.4.26 and later.</p>
+
+<p>See <a href="tech.html#encoding">URL Encoding and Decoding</a> for
+background on how encoding is handled in the rewrite pipeline.</p>
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_bctls" id="flag_bctls">BCTLS</a> <a title="Permanent link" href="#flag_bctls" class="permalink">&para;</a></h2>
@@ -195,6 +201,16 @@ control moves on to the next rule. However, if it does not match, then
 the next rule, and any other rules that are chained together, are
 skipped.</p>
 
+<pre class="prettyprint lang-config"># Rewrite legacy product URLs to the new catalog app,
+# and add a tracking parameter — but only for the rewritten ones.
+RewriteRule "^/products/([0-9]+)$" "/catalog/item/$1" [C]
+RewriteRule "^/catalog/(.*)$" "/catalog/$1?via=legacy" [QSA]</pre>
+
+
+<p>Without the [C] flag, the second rule would also match requests
+that arrive at <code>/catalog/</code> directly. The chain ensures the
+second rule is only applied when the first rule matched.</p>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_co" id="flag_co">CO|cookie</a> <a title="Permanent link" href="#flag_co" class="permalink">&para;</a></h2>
@@ -281,23 +297,25 @@ minutes (24 hours) and is returned for all URIs.</p>
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_dpi" id="flag_dpi">DPI|discardpath</a> <a title="Permanent link" href="#flag_dpi" class="permalink">&para;</a></h2>
-<p>The DPI flag causes the PATH_INFO portion of the rewritten URI to be
+<p>The DPI flag causes the PATH_INFO portion of the rewritten URL-path to be
 discarded.</p>
-<p>In per-directory context, the URI each <code class="directive">RewriteRule</code>
-compares against is the concatenation of the current values of the URI
-and PATH_INFO.</p>
-
-<p>The current URI can be the initial URI as requested by the client, the
-result of a previous round of <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> processing, or the result of
-a prior rule in the current round of <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> processing.</p>
-
-<p>In contrast, the PATH_INFO that is appended to the URI before each
-rule reflects only the value of PATH_INFO before this round of
-<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> processing. As a consequence, if large portions
-of the URI are matched and copied into a substitution in multiple
+
+<p>In <a class="glossarylink" href="../glossary.html#perdirectory" title="see glossary">per-directory context</a>,
+the URL-path each <code class="directive">RewriteRule</code> compares against
+is the concatenation of the current URL-path and PATH_INFO.</p>
+
+<p>The current URL-path can be the initial path as requested by the
+client, the result of a previous round of <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
+processing, or the result of a prior rule in the current round of
+<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> processing.</p>
+
+<p>In contrast, the PATH_INFO that is appended to the URL-path before
+each rule reflects only the value of PATH_INFO before this round of
+<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> processing. As a consequence, if large
+portions of the URL-path are matched and copied into a substitution in multiple
 <code class="directive">RewriteRule</code> directives, without regard for
-which parts of the URI came from the current PATH_INFO, the final
-URI may have multiple copies of PATH_INFO appended to it.</p>
+which parts of the URL-path came from the current PATH_INFO, the final
+URL-path may have multiple copies of PATH_INFO appended to it.</p>
 
 <p>Use this flag on any substitution where the PATH_INFO that resulted
 from the previous mapping of this request to the filesystem is not of
@@ -307,6 +325,17 @@ not be recalculated until the current round of <code class="module"><a href="../
 completes.  Subsequent rules during this round of processing will see
 only the direct result of substitutions, without any PATH_INFO
 appended.</p>
+
+<pre class="prettyprint lang-config"># Request: /app/script.php/extra/path (PATH_INFO is /extra/path)
+# Without DPI, the substitution would see "script.php/extra/path"
+# and could inadvertently copy PATH_INFO into the result.
+RewriteRule "^script\.php(.*)$" "/new-app/handler$1" [DPI]</pre>
+
+
+<p>The [DPI] flag discards <code>/extra/path</code> so that only the
+substitution result (<code>/new-app/handler</code>) is passed to
+subsequent rules or the final request.</p>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_e" id="flag_e">E|env</a> <a title="Permanent link" href="#flag_e" class="permalink">&para;</a></h2>
@@ -348,7 +377,7 @@ contexts, including CGI programs, other RewriteRule directives, or
 CustomLog directives.</p>
 
 <p>The following example sets an environment variable called 'image' to a
-value of '1' if the requested URI is an image file. Then, that
+value of '1' if the requested URL-path is an image file. Then, that
 environment variable is used to exclude those requests from the access
 log.</p>
 
@@ -379,10 +408,33 @@ variable using a RewriteCond:</p>
 
 <p>Note that environment variables do not survive an external
 redirect. You might consider using the [CO] flag to set a
-cookie. For per-directory rewrites, where the final
-substitution is processed as an internal redirect, environment
-variables from the previous round of rewriting are prefixed with
-"REDIRECT_". </p>
+cookie.</p>
+
+    <div class="note"><h3>REDIRECT_ prefix after internal redirects</h3>
+    <p>In <a class="glossarylink" href="../glossary.html#perdirectory" title="see glossary">per-directory context</a>,
+    a successful substitution triggers an internal redirect. When this
+    happens, all environment variables set during the previous pass —
+    including those created with <code>[E=VAR:VAL]</code> — are renamed
+    with a <code>REDIRECT_</code> prefix. A variable you set as
+    <code>rewritten</code> becomes <code>REDIRECT_rewritten</code> in
+    the redirected request.</p>
+
+    <p>To test for the renamed variable, reference it with the
+    prefix:</p>
+    </div>
+
+<pre class="prettyprint lang-config">RewriteRule   "^/horses/(.*)" "/ponies/$1" [E=rewritten:1]
+
+# In the next pass, the variable has been renamed:
+RewriteCond "%{ENV:REDIRECT_rewritten}" =1
+RewriteRule "^/ponies/(.*)" "-" [E=seen_redirect:1,L]</pre>
+
+
+    <p>If the request is redirected multiple times, the prefix stacks:
+    <code>REDIRECT_REDIRECT_rewritten</code>, and so on. See
+    <a href="../env.html#redirect-vars">REDIRECT_ variables</a> for
+    the complete description of this mechanism.</p>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_end" id="flag_end">END</a> <a title="Permanent link" href="#flag_end" class="permalink">&para;</a></h2>
@@ -427,8 +479,8 @@ downloaded from your server.</p>
 
 
 <p>This example uses the "-" syntax for the rewrite target, which means
-that the requested URI is not modified. There's no reason to rewrite to
-another URI, if you're going to forbid the request.</p>
+that the requested URL-path is not modified. There's no reason to rewrite to
+another URL-path, if you're going to forbid the request.</p>
 
 <p>When using [F], an [L] is implied - that is, the response is returned
 immediately, and no further rules are evaluated.</p>
@@ -520,7 +572,7 @@ so until there are no more As to be replaced.
 <pre class="prettyprint lang-config">RewriteRule "(.*)A(.*)" "$1B$2" [N]</pre>
 
 <p>You can think of this as a <code>while</code> loop: While this
-pattern still matches (i.e., while the URI still contains an
+pattern still matches (i.e., while the URL-path still contains an
 <code>A</code>), perform this substitution (i.e., replace the
 <code>A</code> with a <code>B</code>).</p>
 
@@ -538,7 +590,7 @@ RewriteRule "(.+)[&gt;&lt;;]$" "$1" [N=10]</pre>
 <h2><a name="flag_nc" id="flag_nc">NC|nocase</a> <a title="Permanent link" href="#flag_nc" class="permalink">&para;</a></h2>
 <p>Use of the [NC] flag causes the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to be matched in a
 case-insensitive manner. That is, it doesn't care whether letters appear
-as upper-case or lower-case in the matched URI.</p>
+as upper-case or lower-case in the matched URL-path.</p>
 
 <p>In the example below, any request for an image file will be proxied
 to your dedicated image server. The match is case-insensitive, so that
@@ -581,6 +633,9 @@ being converted to its hexcode equivalent, <code>%23</code>, which will
 then result in a 404 Not Found error condition.
 </p>
 
+<p>See <a href="tech.html#encoding">URL Encoding and Decoding</a> for
+the full picture of how Apache encodes and decodes URIs during
+rewriting.</p>
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_ns" id="flag_ns">NS|nosubreq</a> <a title="Permanent link" href="#flag_ns" class="permalink">&para;</a></h2>
@@ -605,6 +660,14 @@ Images, javascript files, or css files, loaded as part of an HTML page,
 are not subrequests - the browser requests them as separate HTTP
 requests.
 </p>
+
+<pre class="prettyprint lang-config"># Only rewrite direct requests to the front controller,
+# not subrequests from SSI includes or mod_dir.
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
+RewriteRule "^(.*)$" "/app/index.php?page=$1" [NS,L]</pre>
+
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_p" id="flag_p">P|proxy</a> <a title="Permanent link" href="#flag_p" class="permalink">&para;</a></h2>
@@ -621,7 +684,7 @@ pushed through the proxy, and any following rules will not be
 considered.</p>
 
 <p>
-You must make sure that the substitution string is a valid URI
+You must make sure that the substitution string is a valid URL
 (typically starting with <code>http://</code><em>hostname</em>) which can be
 handled by the <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>. If not, you will get an
 error from the proxy module. Use this flag to achieve a
@@ -666,7 +729,7 @@ to use this flag.</p>
 <p>
 The target (or substitution string) in a RewriteRule is assumed to be a
 file path, by default. The use of the [PT] flag causes it to be treated
-as a URI instead. That is to say, the
+as a URL-path instead. That is to say, the
 use of the [PT] flag causes the result of the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to be passed back through
 URL mapping, so that location-based mappings, such as <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>, <code class="directive"><a href="../mod/mod_alias.html#redirect">Redirect</a></code>, or <code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>, for example, might have a
 chance to take effect.
@@ -703,7 +766,7 @@ is to rewrite to <code>-</code>.</p>
 <div class="section">
 <h2><a name="flag_qsa" id="flag_qsa">QSA|qsappend</a> <a title="Permanent link" href="#flag_qsa" class="permalink">&para;</a></h2>
 <p>
-When the replacement URI contains a query string, the default behavior
+When the replacement URL contains a query string, the default behavior
 of <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> is to discard
 the existing query string, and replace it with the newly generated one.
 Using the [QSA] flag causes the query strings to be combined.
@@ -724,9 +787,9 @@ will be discarded.
 <div class="section">
 <h2><a name="flag_qsd" id="flag_qsd">QSD|qsdiscard</a> <a title="Permanent link" href="#flag_qsd" class="permalink">&para;</a></h2>
 <p>
-When the requested URI contains a query string, and the target URI does
+When the requested URL contains a query string, and the target URL does
 not, the default behavior of <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> is to copy that query
-string to the target URI. Using the [QSD] flag causes the query string
+string to the target URL. Using the [QSD] flag causes the query string
 to be discarded.
 </p>
 
@@ -737,12 +800,17 @@ Using [QSD] and [QSA] together will result in [QSD] taking precedence.
 </p>
 
 <p>
-If the target URI has a query string, the default behavior will be
+If the target URL has a query string, the default behavior will be
 observed - that is, the original query string will be discarded and
 replaced with the query string in the <code>RewriteRule</code> target
-URI.
+URL.
 </p>
 
+<pre class="prettyprint lang-config"># Redirect old search URLs to the new path, discarding the query string.
+# /search?q=term&amp;page=2  becomes  /find  (query string removed)
+RewriteRule "^/search" "/find" [QSD,R=301,L]</pre>
+
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_qsl" id="flag_qsl">QSL|qslast</a> <a title="Permanent link" href="#flag_qsl" class="permalink">&para;</a></h2>
@@ -800,7 +868,7 @@ status using their symbolic names: <code>temp</code> (default),
 <p>
 You will almost always want to use [R] in conjunction with [L] (that is,
 use [R,L]) because on its own, the [R] flag prepends
-<code>http://thishost[:thisport]</code> to the URI, but then passes this
+<code>http://thishost[:thisport]</code> to the URL-path, but then passes this
 on to the next rule in the ruleset, which can often result in 'Invalid
 URI in request' warnings.
 </p>
@@ -809,6 +877,10 @@ URI in request' warnings.
 spec.  Using an unrecognized status code will result in a 500 error and
 error log message.</p>
 
+<pre class="prettyprint lang-config"># Redirect requests for the old docs path to the new location.
+RewriteRule "^/docs/(.*)$" "http://docs.example.com/$1" [R=301,L]</pre>
+
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_s" id="flag_s">S|skip</a> <a title="Permanent link" href="#flag_s" class="permalink">&para;</a></h2>
@@ -819,7 +891,7 @@ RewriteRule</a></code> and any preceding <code class="directive"><a href="../mod
 RewriteCond</a></code> directives match). This can be thought of as a
 <code>goto</code> statement in your rewrite ruleset. In the following
 example, we only want to run the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">
-RewriteRule</a></code> if the requested URI doesn't correspond with an
+RewriteRule</a></code> if the requested URL-path doesn't correspond with an
 actual file.</p>
 
 <pre class="prettyprint lang-config"># Is the request for a non-existent file?
index 59e15c3cf07320829876c4e53cc9f41eab1d57c9..02b42bc02c4b93771488471bdf77f53d087fbf18 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 1933062:1934122 (outdated) -->
+<!-- English Revision: 1933062:1934234 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 16eb6db976b14baae0a65d75dd9d424b4cc14aea..a20bc07c48fabc3c3ce6ed295b852a6ccddeb86e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.es.xsl"?>
-<!-- English Revision: 1933062:1934122 (outdated) -->
+<!-- English Revision: 1933062:1934234 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 2a956d3ec3e965242265c32fe6753d59fb7b9f16..437bf880fdcc5118cdc44837e3241b7884c3f935 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1933062:1934122 (outdated) -->
+<!-- English Revision: 1933062:1934234 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index 8c4def944e128bcc78b040ff33849aac59c947f9..27977edeb5db60ddc7df3336e2c9d3ba7f4aafe5 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1933062:1934122 (outdated) -->
+<!-- English Revision: 1933062:1934234 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index ecb2a949e5783af1e29f7b7a8fe6315f139898f6..b6ccf3b42b01bbd2c53030de79c932ec6a71eeb6 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='EUC-KR' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 1933062:1934122 (outdated) -->
+<!-- English Revision: 1933062:1934234 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 0fdebc974d585a5c6f4e80bd015169c7752556d6..d966d2398131d7d03a9c9fe8cc0d95e5cc72d88d 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1933062:1934122 (outdated) -->
+<!-- English Revision: 1933062:1934234 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 914fcf445151456c9f1b18498a328ce6cd0c011e..0af1946fb4911148215f2d091fd4269a17d6461d 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.zh-cn.xsl"?>
-<!-- English Revision: 1933062:1934122 (outdated) -->
+<!-- English Revision: 1933062:1934234 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 67a4e3b2a7b2e7c4bf33ccad466a59eefaeb05a1..da4aa5349ce20c84ca2902957f5f988e22ed5ed9 100644 (file)
@@ -52,6 +52,7 @@ processes rules in per-directory context, see the
 <li><img alt="" src="../images/down.gif" /> <a href="#loops">The [L] flag and looping</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#rewritemap-restriction">RewriteMap cannot be
 declared in .htaccess</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#context-restrictions">Which contexts support rewrite rules?</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#inheritance">Rule inheritance with RewriteOptions</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#debugging">Debugging .htaccess rewrite rules</a></li>
 </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li><li><a href="flags.html">RewriteRule Flags</a></li><li><a href="tech.html">Technical details</a></li><li><a href="../mod/mod_rewrite.html#what_is_matched">What is matched?</a></li><li><a href="#comments_section">Comments</a></li></ul></div>
@@ -138,6 +139,23 @@ determines what URL-path prefix is prepended. This subrequest
 mechanism is also why rules can loop — see
 <a href="#loops">below</a>.</p>
 
+
+<p>Because the directory prefix (including the trailing
+slash) is stripped before matching, patterns in
+<a class="glossarylink" href="../glossary.html#perdirectory" title="see glossary">per-directory context</a>
+will <em>never</em> match a leading slash. A pattern
+beginning with <code>^/</code> will never match in this
+context.</p>
+
+<p>If you need to match against the full original
+URL-path (including the directory prefix), use
+<code>%{REQUEST_URI}</code> in a
+<code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>:</p>
+
+<pre class="prettyprint lang-config">RewriteCond "%{REQUEST_URI}" "^/admin/"
+RewriteRule "^.*$" "-" [F]</pre>
+
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="rewritebase" id="rewritebase">When you need RewriteBase</a> <a title="Permanent link" href="#rewritebase" class="permalink">&para;</a></h2>
@@ -277,6 +295,24 @@ parsed on every request, and map initialization (especially for
 <code>dbm:</code>, <code>dbd:</code>, and <code>prg:</code> map types)
 would be prohibitively expensive to repeat each time.</p>
 
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="context-restrictions" id="context-restrictions">Which contexts support rewrite rules?</a> <a title="Permanent link" href="#context-restrictions" class="permalink">&para;</a></h2>
+
+<p>Rewrite rules are supported in
+<a class="glossarylink" href="../glossary.html#perdirectory" title="see glossary">per-directory context</a>
+(<a href="../howto/htaccess.html">.htaccess</a> files,
+<code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code>, and
+<code class="directive"><a href="../mod/core.html#if">&lt;If&gt;</a></code> blocks).</p>
+
+<p>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 (including their regex counterparts), this is
+unsupported and should never be necessary. Relative
+substitutions, in particular, are likely to break in
+these contexts.</p>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="inheritance" id="inheritance">Rule inheritance with RewriteOptions</a> <a title="Permanent link" href="#inheritance" class="permalink">&para;</a></h2>
index 47e4249005b76dbc9f8942583003f99be0e59baa..f4ad1818fa65042d9d0a4c93071e06a1b6c5e4c8 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 1933067:1934108 (outdated) -->
+<!-- English Revision: 1933067:1934228 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 7fc920257e7dfb83213be0bbbdc94cb56e64539c..d0de15d30b76387909884d1028584341f6732893 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.es.xsl"?>
-<!-- English Revision: 1933067:1934108 (outdated) -->
+<!-- English Revision: 1933067:1934228 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 2abe790b64654292c1bb397d4a989dcc7b08f5d8..f3491a2f530a582c77bd76b518b7d0c7d669a95f 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1933067:1934108 (outdated) -->
+<!-- English Revision: 1933067:1934228 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index 7a32ef5482882b2bd49be16184c781216e80e9f5..406cee111f6fc6c85b34881ca331719011cce9ba 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1933067:1934108 (outdated) -->
+<!-- English Revision: 1933067:1934228 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index aa929fd1ee812f796a94caea3c00d029b01fbd56..89650d7805add1907682988ca579e28d14267d36 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='EUC-KR' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 1933067:1934108 (outdated) -->
+<!-- English Revision: 1933067:1934228 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 434cc23e000d231d7e4b01d027de5061906dab4f..737be7b9ffc3efc8e113dcd17149931e9f0b6512 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1933067:1934108 (outdated) -->
+<!-- English Revision: 1933067:1934228 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 4352683bb654064e183d851978b503d527fb2327..21ee8ca5d0e65bbdd392041669fe7af9be753fff 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.zh-cn.xsl"?>
-<!-- English Revision: 1933067:1934108 (outdated) -->
+<!-- English Revision: 1933067:1934228 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index cfd4130bc657dbce501dd805ad36ceaa0562c248..e15a4ede503cf90e995c225e53d7109b8467882f 100644 (file)
@@ -7,7 +7,7 @@
               This file is generated from xml source: DO NOT EDIT
         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       -->
-<title>Le module Apache mod_rewrite - Serveur HTTP Apache Version 2.5</title>
+<title>Guide pour le module Apache mod_rewrite - Serveur HTTP Apache Version 2.5</title>
 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
 <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" />
@@ -21,7 +21,7 @@
 <img alt="" src="../images/feather.png" /></div>
 <div class="up"><a href="../"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
 <div id="path">
-<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">Serveur HTTP</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a></div><div id="page-content"><div id="preamble"><h1>Le module Apache mod_rewrite</h1>
+<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">Serveur HTTP</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a></div><div id="page-content"><div id="preamble"><h1>Guide pour le module Apache mod_rewrite</h1>
 <div class="toplang">
 <p><span>Langues Disponibles: </span><a href="../de/rewrite/" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
 <a href="../en/rewrite/" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
 <a href="../tr/rewrite/" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a> |
 <a href="../zh-cn/rewrite/" hreflang="zh-cn" rel="alternate" title="Simplified Chinese">&nbsp;zh-cn&nbsp;</a></p>
 </div>
-<div class="outofdate">Cette traduction peut être périmée. Vérifiez la version
-            anglaise pour les changements récents.</div>
 
+<p><em>Le point fort de mod_rewrite réside dans le fait qu’il possède toutes les
+capacités de configuration et la flexibilité de Sendmail&nbsp;;mais c’est aussi son
+point faible.</em>
+-- Brian Behlendorf</p>
+
+<p><em>Malgré la multitude d'exemples et de documentations, mod_rewrite est de
+la magie noire. De la magie noire très "cool", mais de la magie noire
+quand-même.</em></p>
 
        <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> permet de modifier les requêtes
        entrantes dynamiquement, en fonction de règles manipulant des <a href="intro.html#regex">expressions rationnelles</a>. Vous pouvez
        ainsi relier des URLs arbitraires à votre propre structure d'URLs
        interne comme vous le souhaitez.</p>
 
-      <p>Il fournit un
-      mécanisme de manipulation d'URL particulièrement souple et
-      puissant en supportant un nombre illimité de règles et de
-      conditions attachées à chaque règle. Les manipulations d'URLs
-      peuvent dépendre de tests variés : les URLs peuvent
-      être finement caractérisées en fonction de variables du serveur,
-      de variables d'environnement, d'en-têtes HTTP, de repères
-      temporels, de recherches dans des bases de données
-      externes, ou même de requêtes vers des bases de données externes
-      et de différents gestionnaires ou programmes externes.</p>
+<p>Ce guide est un complément du <a href="../mod/mod_rewrite.html">manuel de
+référence</a> avec des exemples commentés, des explications conceptuelles et des
+conseils pratiques. Il est organisé comme suit&nbsp;:</p>
+
+<dl>
+<dt><a href="intro.html">Introduction</a></dt>
+<dd>Concepts de base&nbsp;: syntaxe des expressions rationnelles, les bases des
+directives RewriteRule et RewriteCond et la manière dont mod_rewrite s’insère
+dans le cycle de vie du traitement des requêtes.</dd>
+
+<dt><a href="htaccess.html">Réécritures en fonction du répertoire</a></dt>
+<dd>Les principales différences entre l’utilisation des règles de réécriture au
+niveau de la configuration globale du serveur et leur utilisation dans un
+contexte de <a class="glossarylink" href="../glossary.html#perdirectory" title="voir glossaire">répertoire</a>, y compris la
+suppression du chemin, RewriteBase et la gestion du bouclage par le drapeau [L].</dd>
+
+<dt><a href="flags.html">Drapeaux des règles de réécriture</a></dt>
+<dd>Une référence complète de tous les drapeaux qui peuvent modifier le
+comportement d’une règle de réécriture avec des exemples pour chacun d’entre
+eux.</dd>
+
+<dt><a href="rewritemap.html">Utiliser RewriteMap</a></dt>
+<dd>Comment utiliser des sources de recherche externes — fichiers texte,
+bases de données DBM, requêtes SQL et fonctions internes — pour piloter
+vos règles de réécriture.</dd>
+
+<dt><a href="remapping.html">Redirection et remappage</a></dt>
+<dd>Des recettes pour les tâches courantes&nbsp;: redirection HTTPS, noms d’hôte
+canoniques, normalisation des barres obliques de fin, routage du contrôleur
+frontal, et plus encore.</dd>
 
-      <p>Les règles de réécriture peuvent agir sur l'ensemble des URLs (la partie chemin
-      et la chaîne de paramètres) et peuvent être utilisées dans le contexte du serveur principal
-      (<code>httpd.conf</code>), mais aussi dans le contexte des
-      serveurs virtuels (sections <code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>), ou dans le
-      contexte des
-      répertoires (fichiers <code>.htaccess</code> et blocs
-      <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code>). Le résultat
-      réécrit peut conduire vers d'autres règles à un
-      traitement secondaire interne, une redirection vers une requête
-      externe ou même l'envoi vers un serveur mandataire, en fonction
-      des  <a href="flags.html">drapeaux</a> que vous attachez aux
-      règles</p>
+<dt><a href="vhosts.html">Serveurs virtuels dynamiques</a></dt>
+<dd>Utilisation de mod_rewrite pour associer dynamiquement les noms d’hôte aux
+racines de document sans devoir créer des blocs VirtualHost individuels.</dd>
 
-       <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> étant très puissant, il peut par
-       conséquent être très complexe. Ce document
-       complète la <a href="../mod/mod_rewrite.html">documentation de
-      référence du module mod_rewrite</a>, et est sensé alléger un
-      peu cette complexité, et présenter des exemples largement
-      commentés, ainsi que des situations courantes que vous
-      pourrez traiter avec <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. Mais nous voulons aussi vous
-      montrer des situations où vous ne devrez pas utiliser
-      <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>, et lui préférer d'autres
-      fonctionnalités standard d'Apache, évitant ainsi
-      d'entrer dans une complexité inutile.</p>
+<dt><a href="avoid.html">Quand ne pas utiliser mod_rewrite</a></dt>
+<dd>De nombreuses tâches courantes sont accomplies de manière bien plus efficace
+avec des directives plus simples. Ce document vous propose des solutions de
+remplacement et vous indique quand il est préférable de les utiliser.</dd>
 
-<ul>
-<li><a href="../mod/mod_rewrite.html">documentation de
-référence de mod_rewrite</a></li>
-<li><a href="intro.html">Introduction aux expressions rationnelles et à
-mod_rewrite</a></li>
-<li><a href="flags.html">Drapeaux de réécriture</a></li>
-<li><a href="rewritemap.html">Utilisation de  RewriteMap</a></li>
-<li><a href="avoid.html">Quand <strong>NE PAS</strong> utiliser mod_rewrite</a></li>
-<li><a href="remapping.html">Utilisation de mod_rewrite pour la
-redirection et la remise en correspondance des URLs</a></li>
-<li><a href="access.html">Utilisation de mod_rewrite pour le
-contrôle d'accès</a></li>
-<li><a href="vhosts.html">Les serveurs virtuels dynamiques avec mod_rewrite</a></li>
-<li><a href="proxy.html">Les serveurs mandataires dynamiques avec mod_rewrite</a></li>
-<li><a href="advanced.html">Techniques avancées</a></li>
-<li><a href="tech.html">Détails techniques</a></li>
-</ul>
+<dt><a href="tech.html">Détails techniques</a></dt>
+<dd>Comment mod_rewrite s’insère dans les phases de traitement des requêtes par
+httpd et l’ordre dans lequel les règles et les conditions sont évaluées.</dd>
+</dl>
 </div>
 <div id="quickview"><h3>Voir aussi</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Documentation de
 référence de mod_rewrite</a></li><li><a href="../urlmapping.html">Mise en correspondance des URLs
index a9796fffe527216aabaa2374704b561b7aeadbcc..0bb34a8711b6f20a612c886eac89996f8d4dcec1 100644 (file)
@@ -10,7 +10,7 @@
     <variant outdated="yes">de</variant>
     <variant>en</variant>
     <variant outdated="yes">es</variant>
-    <variant outdated="yes">fr</variant>
+    <variant>fr</variant>
     <variant outdated="yes">ja</variant>
     <variant outdated="yes">ko</variant>
     <variant outdated="yes">tr</variant>
index 0ecd6271bd6ff342132bb977fb341998c2b64741..838be46b5a26f55403e4c3afff402d1bf9cc19f3 100644 (file)
@@ -171,11 +171,22 @@ well as write your own.</p>
       not <code>c/t</code></td></tr>
 </table>
 
-<p>In <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> the <code>!</code> character can be
+<p>The <code>!</code> (Not) character can be
 used before a regular expression to negate it. This is, a string will
 be considered to have matched only if it does not match the rest of
 the expression.</p>
 
+<p>When using <code>!</code> to negate a pattern, note that
+<a href="#InternalBackRefs">backreferences</a> (e.g.
+<code>$1</code>, <code>$2</code>) are not available, since the
+pattern does not match.</p>
+
+<p>For example, the following will redirect any request that does
+<em>not</em> start with <code>/admin</code></p>
+
+<pre class="prettyprint lang-config">RewriteRule "!^/admin" "/xyz.html" [R,L]</pre>
+
+
 
 
 <h3><a name="InternalBackRefs" id="InternalBackRefs">Regex Back-Reference Availability</a></h3>
@@ -222,15 +233,27 @@ of three arguments separated by spaces. The arguments are</p>
 </ol>
 
 <p>The <var>Pattern</var> is a <a href="#regex">regular expression</a>.
-It is initially (for the first rewrite rule or until a substitution occurs)
-matched against the URL-path of the incoming request (the part after the
-hostname but before any question mark indicating the beginning of a query
-string) or, in per-directory context, against the request's path relative
-to the directory for which the rule is defined. Once a substitution has
-occurred, the rules that follow are matched against the substituted
-value.
+In server or virtualhost context, it is matched against the
+%-decoded <a href="../directive-dict.html#Syntax">URL-path</a>
+of the incoming request — the part after the hostname and port,
+and not including the query string (e.g., <code>/app/index.html</code>).
+In <a class="glossarylink" href="../glossary.html#perdirectory" title="see glossary">per-directory context</a>,
+the pattern is matched against the request's path relative to the
+directory for which the rule is defined (with the directory prefix
+stripped — see <a href="htaccess.html#path-stripping">Per-directory
+Rewrites</a> for details).
 </p>
 
+<p>Once a substitution has occurred, any rules that follow are
+matched against the substituted value.</p>
+
+<p>The <var>Pattern</var> is matched only against the URL-path
+— not the hostname, port, or query string. To match against
+those, use a
+<code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> with the
+<code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
+<code>%{QUERY_STRING}</code> variables respectively.</p>
+
 <p class="figure">
       <img src="../images/syntax_rewriterule.png" alt="Syntax of the RewriteRule directive" /><br />
       <dfn>Figure 2:</dfn> Syntax of the RewriteRule directive.
index d548d3d7bddd50679919ea5a687e3ba611b27bf2..696871ffc5ee271361cf5d6b5d2d274519b5fe01 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 1933423:1934122 (outdated) -->
+<!-- English Revision: 1933423:1934230 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 42932b0ed93954fd4884b204aac646f61af2a9be..f6dc9d5faeb75cc3a9b6ded1d3bc7044e0b8808c 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.es.xsl"?>
-<!-- English Revision: 1933423:1934122 (outdated) -->
+<!-- English Revision: 1933423:1934230 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 1d9aee8a7cfc86e954346d8a51b4df54677199a0..3e734e22b51aeeacfdce2ec68ef0e321225f6f62 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1933423:1934122 (outdated) -->
+<!-- English Revision: 1933423:1934230 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index d2360a51f919b36ab02d37982611a0a7cb146193..7f09e6c078e46f0b55a70993af52e6f13d956fd9 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1933423:1934122 (outdated) -->
+<!-- English Revision: 1933423:1934230 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 34032df36900490ff9ba3ef1cd84fba463e0cb21..5ced2c58a0b161ed83d3064333fd774508f42931 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='EUC-KR' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 1933423:1934122 (outdated) -->
+<!-- English Revision: 1933423:1934230 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 0317eb9fef3dccab0ef6c5641d9ce1d10972f0b0..a9e2703a79b54c1706663a779c00b48dc703c528 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1933423:1934122 (outdated) -->
+<!-- English Revision: 1933423:1934230 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 88e3025e81ca12ee795069cc023ddfcb5ac33339..b9912ba5f5a6581fc0b35eafaab479c5c925d976 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.zh-cn.xsl"?>
-<!-- English Revision: 1933423:1934122 (outdated) -->
+<!-- English Revision: 1933423:1934230 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 52ca8024e99a60e05d325bd57168ca9e10aca7b7..1d83506f6a1078ded832deec017bfd624743c5e5 100644 (file)
@@ -145,6 +145,35 @@ RewriteRule "^(.*)" "https://%{SERVER_NAME}$1" [R=301,L]</pre>
       <p>See also the <a href="avoid.html#redirect">When not to use
       mod_rewrite</a> document for more discussion of the
       <code>Redirect</code> approach.</p>
+
+      <div class="note"><h3>Behind a load balancer or SSL terminator</h3>
+      <p>The <code>%{HTTPS}</code> variable is not a general-purpose
+      environment variable — it queries <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>
+      directly. If SSL/TLS is terminated at an upstream load balancer
+      or reverse proxy, <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> is not handling the
+      connection and <code>%{HTTPS}</code> will always report
+      <code>off</code>, even when the original client connected over
+      HTTPS.</p>
+
+      <p>In this situation, check the header set by the upstream proxy
+      instead. Most load balancers set
+      <code>X-Forwarded-Proto</code>:</p>
+      </div>
+
+<pre class="prettyprint lang-config">RewriteEngine On
+RewriteCond "%{HTTP:X-Forwarded-Proto}" =http [NC]
+RewriteRule "^(.*)" "https://%{SERVER_NAME}$1" [R=301,L]</pre>
+
+
+      <div class="warning">
+      <p>Only trust <code>X-Forwarded-Proto</code> if you control the
+      upstream proxy and it overwrites the header on every request. An
+      attacker can forge this header when connecting directly to your
+      server. Consider restricting access so that only your load
+      balancer can reach the backend, or use
+      <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> to validate the source.</p>
+      </div>
+
     </dd>
   </dl>
 
index 9a01e545e9fe1508fcb75d971b7d32a2b3753401..6488b2898eb9020eeaf33bb8bb2520b299cf4b0a 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 1933068:1934122 (outdated) -->
+<!-- English Revision: 1933068:1934200 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 74a04de8fe26cf0005c8cfe040e67da59a30bb01..9ca19cb955e26f654f544e6b541f5269d4782359 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.es.xsl"?>
-<!-- English Revision: 1933068:1934122 (outdated) -->
+<!-- English Revision: 1933068:1934200 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index f2648bd217b355b6226b7ea123c2b7ce4081d5be..da49dd6c3c062ecaf9917243e1511d38d8e3a51f 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1933068:1934122 (outdated) -->
+<!-- English Revision: 1933068:1934200 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index dcd8a3f60f0044ed4951ac6dc2df7d9f27bbe22c..79d09150d0b1dd7ea5842cdc3b0a6fe0e67ff764 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1933068:1934122 (outdated) -->
+<!-- English Revision: 1933068:1934200 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index cfd48bc042667e01311c29c8c9c472150d5564eb..c14cf11b6cc3b5dac834f920c41ae2f1e9b03a0f 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='EUC-KR' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 1933068:1934122 (outdated) -->
+<!-- English Revision: 1933068:1934200 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 6a4e49c50d14771e43f1b989f80a5a39134dd0bc..ece1d0b463d85771bfb450a465b091e836a31de0 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1933068:1934122 (outdated) -->
+<!-- English Revision: 1933068:1934200 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 88924d8200b4c7f5ee8500fadf22c5599bbe1fe2..90c0916c9ff8709f616a3f18baca4755306b3f4a 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.zh-cn.xsl"?>
-<!-- English Revision: 1933068:1934122 (outdated) -->
+<!-- English Revision: 1933068:1934200 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index a4ab7bca1f5cbf48ab161abbc53fad698803de24..ebe01441d5177a750fb67980e931d861d17b84dc 100644 (file)
@@ -152,7 +152,7 @@ may be used, and give examples of each.</p>
     the int function, and then use that in your <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>:
     </p>
 
-   <p> <strong>Redirect a URI to an all-lowercase version of itself</strong></p>
+   <p> <strong>Redirect a URL-path to an all-lowercase version of itself</strong></p>
     <pre class="prettyprint lang-config">RewriteMap lc int:tolower
 RewriteRule "(.*)" "${lc:$1}" [R]</pre>
 
@@ -387,7 +387,7 @@ by many requests.
     <code class="directive"><a href="../mod/core.html#mutex">Mutex</a></code> directive.</p>
 
     <p>A simple example is shown here which will replace all dashes with
-    underscores in a request URI.</p>
+    underscores in a request URL-path.</p>
 
     <p><strong>Rewrite configuration</strong></p>
     <pre class="prettyprint lang-config">RewriteMap d2u "prg:/www/bin/dash2under.py" apache:apache
index b056890733960bb0827fb0aafb4801a868cdfcec..4c07d29bf8f7a2f126dcbad21e36150df2e7db99 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 1932819:1934122 (outdated) -->
+<!-- English Revision: 1932819:1934233 (outdated) -->
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
index d315154e1b3af51afe47cf1b262281ab229d3097..8eee48813ae3d0808161cb2509a3dc6efda4075f 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.es.xsl"?>
-<!-- English Revision: 1932819:1934122 (outdated) -->
+<!-- English Revision: 1932819:1934233 (outdated) -->
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
index 54babf53fe6ebc426b82696ce0fe9319f827aa30..b497a291574f9b622dc473225d32e166288a87a5 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1932819:1934122 (outdated) -->
+<!-- English Revision: 1932819:1934233 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index 74adafdef956b7466ea1023549f3b08721d66e1d..478ad419dd5204ca052011a6a456d1e1f685f2db 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1932819:1934122 (outdated) -->
+<!-- English Revision: 1932819:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 1ae03347c9d4355a2895cd593fd439d73a7e0a7e..143fb47d63b71dd4e1edb000ddcdd19e9ebf5c33 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='EUC-KR' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 1932819:1934122 (outdated) -->
+<!-- English Revision: 1932819:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 92e2ee081bf0d1079e5d9a6e4aef581f23640216..d51a17f272c1c687609659b79dcac95af3f2c80b 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1932819:1934122 (outdated) -->
+<!-- English Revision: 1932819:1934233 (outdated) -->
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
index b619073c2fad69aad39775af3fbf393fe482045b..a98895a3dc62586835af9c53dbd6e0f42d276032 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.zh-cn.xsl"?>
-<!-- English Revision: 1932819:1934122 (outdated) -->
+<!-- English Revision: 1932819:1934233 (outdated) -->
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
index d7f939f436191205a4d46aa3b352a6a0f93b122f..1dc367026e1b0c061476537b9bc7cddd495dbded 100644 (file)
@@ -37,6 +37,8 @@
 and URL matching.</p>
 </div>
 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#InternalAPI">API Phases</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#order">Module Processing Order</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#encoding">URL Encoding and Decoding</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#InternalRuleset">Ruleset Processing</a></li>
 </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="flags.html">RewriteRule Flags</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="htaccess.html">Per-directory Rewrites</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li><li><a href="#comments_section">Comments</a></li></ul></div>
 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
@@ -82,6 +84,117 @@ and URL matching.</p>
     document for practical details on path stripping, RewriteBase, and
     how to avoid looping.</p>
 
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="order" id="order">Module Processing Order</a> <a title="Permanent link" href="#order" class="permalink">&para;</a></h2>
+
+    <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> and <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> both
+    operate during the URL-to-filename translation phase, but
+    <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> runs <strong>first</strong> regardless
+    of the order in which directives appear in the configuration file.
+    This is determined by the hook priority each module registers, not
+    by source order.</p>
+
+    <p>The practical consequence: when both <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> and <code class="directive"><a href="../mod/mod_alias.html#redirect">Redirect</a></code> (or <code class="directive"><a href="../mod/mod_alias.html#redirectmatch">RedirectMatch</a></code>) are present in the
+    same server or virtual-host context, the rewrite rules are
+    evaluated first. If a <code>RewriteRule</code> matches and rewrites
+    the URL-path (or returns a redirect), <code>Redirect</code> never sees
+    the request.</p>
+
+    <pre class="prettyprint lang-config"># In this configuration, the Redirect is never reached for /old
+# because the RewriteRule matches first — even though
+# the Redirect appears earlier in the file.
+Redirect "/old" "http://example.com/new"
+RewriteRule "^/old" "/other" [L]</pre>
+
+
+    <div class="note"><h3>Per-directory context reverses the order</h3>
+    <p>In <a class="glossarylink" href="../glossary.html#perdirectory" title="see glossary">per-directory context</a>,
+    the situation is different. <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> directives like
+    <code>Redirect</code> still run in the URL-to-filename translation
+    phase, but <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> rules run later, in the
+    Fixup phase. This means that in per-directory context,
+    <code>Redirect</code> is evaluated <em>before</em>
+    <code>RewriteRule</code>.</p>
+    </div>
+
+    <p>Because of this inconsistency between contexts, mixing
+    <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> and <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code>
+    directives in the same scope is a common source of confusion. The
+    simplest advice: choose one module for a given task. If you need
+    rewrite conditions or pattern matching, use
+    <code>RewriteRule</code> exclusively. If a simple prefix redirect
+    suffices, use <code>Redirect</code> and don't add rewrite rules
+    that might interact with it.</p>
+
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="encoding" id="encoding">URL Encoding and Decoding</a> <a title="Permanent link" href="#encoding" class="permalink">&para;</a></h2>
+
+    <p>Apache httpd unescapes URL-encoded characters in the request URL-path before any
+    <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> pattern
+    matching takes place. A request for
+    <code>/my%20page/cats%3Fdogs</code> is decoded to
+    <code>/my page/cats?dogs</code>, and that decoded string is what the
+    <code>RewriteRule</code> pattern matches against.</p>
+
+    <p>This means you cannot write a pattern that matches the literal
+    URL-encoded form. If you need to distinguish
+    <code>/horses%2Fponies</code> from <code>/horses/ponies</code>, use
+    <code>%{THE_REQUEST}</code> in a <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> — it preserves the
+    original request line exactly as the client sent it, before any
+    decoding:</p>
+
+<pre class="prettyprint lang-config"># Match only the literally-encoded %2F, not a real path separator
+RewriteCond "%{THE_REQUEST}" "/horses%2F"
+RewriteRule "^/horses/ponies$" "/special-handler" [L]</pre>
+
+
+    <p>After substitution, <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> re-encodes the
+    resulting URL-path for output. Several flags control this behavior:</p>
+
+    <ul>
+      <li><a href="flags.html#flag_b">[B]</a> — re-escape
+      backreferences so that special characters captured from the
+      decoded URL-path are not interpreted as delimiters in the
+      substitution.</li>
+
+      <li><a href="flags.html#flag_bnp">[BNP]</a> — when [B] is
+      active, encode spaces as <code>%20</code> rather than
+      <code>+</code> (appropriate for path components, not query
+      strings).</li>
+
+      <li><a href="flags.html#flag_ne">[NE]</a> — suppress the
+      default escaping of special characters in the substitution
+      result, allowing literal <code>#</code>, <code>?</code>, and
+      other characters to pass through unmodified on external
+      redirects.</li>
+    </ul>
+
+    <h3><a name="allowencodedslashes" id="allowencodedslashes">AllowEncodedSlashes</a></h3>
+    
+
+    <p>By default, Apache returns 404 for any URL containing an encoded
+    slash (<code>%2F</code>). The <code class="directive"><a href="../mod/core.html#allowencodedslashes">AllowEncodedSlashes</a></code> directive controls
+    this behavior:</p>
+
+    <ul>
+      <li><code>Off</code> (default) — reject <code>%2F</code> with
+      404.</li>
+      <li><code>On</code> — allow <code>%2F</code> and decode it to
+      <code>/</code> before passing to handlers.</li>
+      <li><code>NoDecode</code> — allow <code>%2F</code> but keep it
+      in encoded form, letting the backend application distinguish it
+      from a real path separator.</li>
+    </ul>
+
+    <p>When using the <a href="flags.html#flag_b">[B]</a> flag with
+    URLs that may contain encoded slashes, you typically need
+    <code>AllowEncodedSlashes NoDecode</code> to prevent Apache from
+    rejecting the re-encoded result.</p>
+
+    
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="InternalRuleset" id="InternalRuleset">Ruleset Processing</a> <a title="Permanent link" href="#InternalRuleset" class="permalink">&para;</a></h2>
index 9e2add121fb9ea2ac92bae415a599ec125778c2b..8cf9f4be676da3f2e014888f6eef51ef83e0b2d5 100644 (file)
@@ -41,7 +41,7 @@ module <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></c
 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#InternalAPI">Phases de l'API</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#InternalRuleset">Traitement du jeu de règles</a></li>
 </ul><h3>Voir aussi</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Documentation du module mod_rewrite</a></li><li><a href="intro.html">Introduction à mod_rewrite</a></li><li><a href="remapping.html">Redirection et remise en
-correspondance</a></li><li><a href="access.html">Contrôle d'accès</a></li><li><a href="vhosts.html">Serveurs virtuels</a></li><li><a href="proxy.html">Mise en cache</a></li><li><a href="rewritemap.html">Utilisation de RewriteMap</a></li><li><a href="advanced.html">Techniques avancées</a></li><li><a href="avoid.html">Quand ne pas utiliser mod_rewrite</a></li><li><a href="#comments_section">Commentaires</a></li></ul></div>
+correspondance</a></li><li><a href="flags.html">Drapeaux de réécriture</a></li><li><a href="vhosts.html">Serveurs virtuels</a></li><li><a href="rewritemap.html">Utilisation de RewriteMap</a></li><li><a href="htaccess.html">Réécritures en fonction du répertoire</a></li><li><a href="avoid.html">Quand ne pas utiliser mod_rewrite</a></li><li><a href="#comments_section">Commentaires</a></li></ul></div>
 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="InternalAPI" id="InternalAPI">Phases de l'API</a> <a title="Lien permanent" href="#InternalAPI" class="permalink">&para;</a></h2>
@@ -83,66 +83,12 @@ correspondance</a></li><li><a href="access.html">Contrôle d'accès</a></li><li>
     <code>REQUEST_URI</code> soit vers une nouvelle URL, soit vers un
     nom de fichier.</p>
 
-    <p>Dans un contexte de niveau répertoire (autrement dit dans les
-    fichiers <code>.htaccess</code> et les sections
-    <code>Directory</code>), les règles de réécriture s'appliquent après
-    la traduction de l'URL en nom de fichier. C'est pourquoi le chemin
-    URL auquel <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> compare initialement les directives
-    <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> est le
-    chemin complet vers le nom de fichier traduit amputé de la partie
-    répertoires (y compris le dernier slash).</p>
-
-    <p>Un exemple : si les règles se trouvent dans
-    /var/www/foo/.htaccess et si une requête pour /foo/bar/baz est
-    traité, une expression comme ^bar/baz$ correspondra.</p>
-
-    <p>Si une substitution intervient dans un contexte de répertoire,
-    une nouvelle sous-requête interne est générée avec la nouvelle URL,
-    ce qui relance le traitement des phases de la requête. Si la
-    substitution est un chemin relatif, la directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritebase">RewriteBase</a></code> détermine le chemin URL
-    devant préfixer cette substitution. Dans un contexte de répertoire,
-    il faut s'assurer de créer des règles qui
-    n'effectueront pas de substitution au
-    cours d'une passe ultérieure du processus de réécriture au niveau
-    répertoire afin d'éviter les bouclages . Voir <a href="https://cwiki.apache.org/confluence/display/httpd/RewriteLooping">Bouclage dans le
-    processus de réécriture</a> pour une discussion plus détaillée à
-    propos de ce problème.</p>
-
-    <p>En conséquence de cette manipulation de l'URL , vous devrez
-    pensez à confectionner différemment vos règles de réécriture dans un
-    contexte de niveau répertoire. En particulier, rappelez-vous que le
-    chemin de répertoire sera absent de l'URL que vos règles de
-    réécriture verront. Voici quelques exemples qui permettront de
-    clarifier les choses :</p>
-
-    <table class="bordered">
-
-        <tr>
-            <th>Position de la règle</th>
-            <th>Règle</th>
-        </tr>
-
-        <tr>
-            <td>Section VirtualHost</td>
-            <td>RewriteRule "^/images/(.+)\.jpg" "/images/$1.gif"</td>
-        </tr>
-
-        <tr>
-            <td>Fichier .htaccess à la racine des documents</td>
-            <td>RewriteRule "^images/(.+)\.jpg" "images/$1.gif"</td>
-        </tr>
-
-        <tr>
-            <td>Fichier .htaccess dans le répertoire images</td>
-            <td>RewriteRule "^(.+)\.jpg" "$1.gif"</td>
-        </tr>
-
-    </table>
-
-    <p>Pour une étude plus approfondie de la manière dont <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
-    manipule les URLs dans les différents contextes, vous pouvez
-    consulter les <a href="../mod/mod_rewrite.html#logging">entrées du
-    journal</a> générées au cours du processus de réécriture.</p>
+    <p>Dans un <a class="glossarylink" href="../glossary.html#perdirectory" title="voir glossaire">contexte de répertoire</a>,
+    les règles sont appliquées durant la phase "Fixup" après que l’URL a été
+    traduite en nom de fichier. Cela modifie ce à quoi correspond le motif et la
+    manière dont les substitutions sont gérées. Voir le document <a href="htaccess.html#path-stripping">Réécritures en fonction du
+    répertoire</a> pour des détails pratiques à propos de la suppression du
+    chemin, de RewriteBase et de la manière d’éviter un bouclage.</p>
 
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
index 8340900b4503a46c642c1c3b82b1f402251b90fd..19484079b4f4b43afb1fb00d3e127911743680da 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 1933438:1934122 (outdated) -->
+<!-- English Revision: 1933438:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index fad8fdcf6a0cca5f88d10f26b86d2c74ed0f05d6..d0fcde8e8a6c106f00edf90f6d75d93ad7a61d1c 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.es.xsl"?>
-<!-- English Revision: 1933438:1934122 (outdated) -->
+<!-- English Revision: 1933438:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 5f6431bb1ae73e2c66511cc86f203c9084aa9809..70c9c2d449e330cc1fe17a8e0670034022932bf1 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1934122 -->
+<!-- English Revision: 1934122:1934233 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index 5af254104f8103c43dc7c241a99eb2dd2f951a5a..00abb3ebccb4a5b83b731b2ef0eef23a1d91f47e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1933438:1934122 (outdated) -->
+<!-- English Revision: 1933438:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 68318f3c98fd0445192f94ca39ebe05d05b5008e..03748e67cf75854433e4e229a28a8888a0f145ca 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='EUC-KR' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 1933438:1934122 (outdated) -->
+<!-- English Revision: 1933438:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index b78f0997936156bb021ed405dca4d95e8c0441be..1833d55a1c425e2117506c88a2f61512cbbd06b5 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1933438:1934122 (outdated) -->
+<!-- English Revision: 1933438:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
index 13ae13e3a6a6f80f4fd832350d8de1bcbc8d7cd7..12439861f179ae241477873789649ed0e04ac4fe 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.zh-cn.xsl"?>
-<!-- English Revision: 1933438:1934122 (outdated) -->
+<!-- English Revision: 1933438:1934233 (outdated) -->
 
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more