summaryrefslogtreecommitdiffstats
path: root/docs/manual/rewrite/intro.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/manual/rewrite/intro.html2
-rw-r--r--docs/manual/rewrite/intro.html.en152
-rw-r--r--docs/manual/rewrite/intro.html.fr.utf8142
3 files changed, 184 insertions, 112 deletions
diff --git a/docs/manual/rewrite/intro.html b/docs/manual/rewrite/intro.html
index 989967f..53af197 100644
--- a/docs/manual/rewrite/intro.html
+++ b/docs/manual/rewrite/intro.html
@@ -2,7 +2,7 @@
URI: intro.html.en
Content-Language: en
-Content-type: text/html; charset=ISO-8859-1
+Content-type: text/html; charset=UTF-8
URI: intro.html.fr.utf8
Content-Language: fr
diff --git a/docs/manual/rewrite/intro.html.en b/docs/manual/rewrite/intro.html.en
index 9e9963d..c37be63 100644
--- a/docs/manual/rewrite/intro.html.en
+++ b/docs/manual/rewrite/intro.html.en
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
-<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
+<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<!--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This file is generated from xml source: DO NOT EDIT
@@ -24,7 +24,7 @@
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.4</a> &gt; <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Introduction</h1>
<div class="toplang">
<p><span>Available Languages: </span><a href="../en/rewrite/intro.html" title="English">&nbsp;en&nbsp;</a> |
-<a href="../fr/rewrite/intro.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
+<a href="../fr/rewrite/intro.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
</div>
<p>This document supplements the <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
@@ -73,7 +73,7 @@ it will tell you exactly how each rule is processed.</p>
<div class="section">
<h2><a name="regex" id="regex">Regular Expressions</a></h2>
-<p>mod_rewrite uses the <a href="http://pcre.org/">Perl Compatible
+<p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> uses the <a href="http://pcre.org/">Perl Compatible
Regular Expression</a> vocabulary. In this document, we do not attempt
to provide a detailed reference to regular expressions. For that, we
recommend the <a href="http://pcre.org/pcre.txt">PCRE man pages</a>, the
@@ -101,32 +101,65 @@ well as write your own.</p>
<th>Example</th>
</tr>
-<tr><td><code>.</code></td><td>Matches any single
-character</td><td><code>c.t</code> will match <code>cat</code>,
-<code>cot</code>, <code>cut</code>, etc.</td></tr>
-<tr><td><code>+</code></td><td>Repeats the previous match one or more
-times</td><td><code>a+</code> matches <code>a</code>, <code>aa</code>,
-<code>aaa</code>, etc</td></tr>
-<tr><td><code>*</code></td><td>Repeats the previous match zero or more
-times.</td><td><code>a*</code> matches all the same things
-<code>a+</code> matches, but will also match an empty string.</td></tr>
-<tr><td><code>?</code></td><td>Makes the match optional.</td><td>
-<code>colou?r</code> will match <code>color</code> and <code>colour</code>.</td>
+<tr>
+ <td><code>.</code></td>
+ <td>Matches any single character</td>
+ <td><code>c.t</code> will match <code>cat</code>, <code>cot</code>,
+ <code>cut</code>, etc</td>
+</tr>
+<tr>
+ <td><code>+</code></td>
+ <td>Repeats the previous match one or more times</td>
+ <td><code>a+</code> matches <code>a</code>, <code>aa</code>,
+ <code>aaa</code>, etc</td>
+</tr>
+<tr>
+ <td><code>*</code></td>
+ <td>Repeats the previous match zero or more times</td>
+ <td><code>a*</code> matches all the same things <code>a+</code> matches,
+ but will also match an empty string</td>
+</tr>
+<tr>
+ <td><code>?</code></td>
+ <td>Makes the match optional</td>
+ <td><code>colou?r</code> will match <code>color</code> and
+ <code>colour</code></td>
+</tr>
+<tr>
+ <td><code>\</code></td>
+ <td>Escape the next character</td>
+ <td><code>\.</code> will match <code>.</code> (dot) and not <em>any single
+ character</em> as explain above</td>
+</tr>
+<tr>
+ <td><code>^</code></td>
+ <td>Called an anchor, matches the beginning of the string</td>
+ <td><code>^a</code> matches a string that begins with <code>a</code></td>
+</tr>
+<tr>
+ <td><code>$</code></td>
+ <td>The other anchor, this matches the end of the string</td>
+ <td><code>a$</code> matches a string that ends with <code>a</code></td>
+</tr>
+<tr>
+ <td><code>( )</code></td>
+ <td>Groups several characters into a single unit, and captures a match
+ for use in a backreference</td>
+ <td><code>(ab)+</code> matches <code>ababab</code> - that is, the
+ <code>+</code> applies to the group. For more on backreferences see
+ <a href="#InternalBackRefs">below</a></td>
</tr>
-<tr><td><code>^</code></td><td>Called an anchor, matches the beginning
-of the string</td><td><code>^a</code> matches a string that begins with
-<code>a</code></td></tr>
-<tr><td><code>$</code></td><td>The other anchor, this matches the end of
-the string.</td><td><code>a$</code> matches a string that ends with
-<code>a</code>.</td></tr>
-<tr><td><code>( )</code></td><td>Groups several characters into a single
-unit, and captures a match for use in a backreference.</td><td><code>(ab)+</code>
-matches <code>ababab</code> - that is, the <code>+</code> applies to the group.
-For more on backreferences see <a href="#InternalBackRefs">below</a>.</td></tr>
-<tr><td><code>[ ]</code></td><td>A character class - matches one of the
-characters</td><td><code>c[uoa]t</code> matches <code>cut</code>,
-<code>cot</code> or <code>cat</code>.</td></tr>
-<tr><td><code>[^ ]</code></td><td>Negative character class - matches any character not specified</td><td><code>c[^/]t</code> matches <code>cat</code> or <code>c=t</code> but not <code>c/t</code></td></tr>
+<tr>
+ <td><code>[ ]</code></td>
+ <td>A character class - matches one of the characters</td>
+ <td><code>c[uoa]t</code> matches <code>cut</code>, <code>cot</code> or
+ <code>cat</code></td>
+</tr>
+<tr>
+ <td><code>[^ ]</code></td>
+ <td>Negative character class - matches any character not specified</td>
+ <td><code>c[^/]t</code> matches <code>cat</code> or <code>c=t</code> but
+ 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
@@ -143,21 +176,21 @@ the expression.</p>
<em>CondPattern</em>, back-references are internally created
which can be used with the strings <code>$N</code> and
<code>%N</code> (see below). These are available for creating
- the <em>Substitution</em> parameter of a
+ the <em>Substitution</em> parameter of a
<code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> or
- the <em>TestString</em> parameter of a
+ the <em>TestString</em> parameter of a
<code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>.</p>
- <p> Captures in the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> patterns are (counterintuitively) available to
- all preceding
+ <p> Captures in the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> patterns are (counterintuitively) available to
+ all preceding
<code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> directives,
because the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>
expression is evaluated before the individual conditions.</p>
- <p>Figure 1 shows to which
- locations the back-references are transferred for expansion as
- well as illustrating the flow of the RewriteRule, RewriteCond
- matching. In the next chapters, we will be exploring how to use
- these back-references, so do not fret if it seems a bit alien
+ <p>Figure 1 shows to which
+ locations the back-references are transferred for expansion as
+ well as illustrating the flow of the RewriteRule, RewriteCond
+ matching. In the next chapters, we will be exploring how to use
+ these back-references, so do not fret if it seems a bit alien
to you at first.
</p>
@@ -179,12 +212,12 @@ of three arguments separated by spaces. The arguments are</p>
<li><var>[flags]</var>: options affecting the rewritten request.</li>
</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
+<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.
</p>
@@ -198,25 +231,26 @@ value.
<p>The <var>Substitution</var> can itself be one of three things:</p>
<dl>
-<dt>A full filesystem path to a resource</dt>
+<dt>1. A full filesystem path to a resource</dt>
<dd>
-<pre class="prettyprint lang-config">RewriteRule "^/games" "/usr/local/games/web"</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/games" "/usr/local/games/web/puzzles.html"</pre>
<p>This maps a request to an arbitrary location on your filesystem, much
like the <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> directive.</p>
</dd>
-<dt>A web-path to a resource</dt>
+<dt>2. A web-path to a resource</dt>
<dd>
-<pre class="prettyprint lang-config">RewriteRule "^/foo$" "/bar"</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/games$" "/puzzles.html"</pre>
<p>If <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> is set
to <code>/usr/local/apache2/htdocs</code>, then this directive would
-map requests for <code>http://example.com/foo</code> to the
-path <code>/usr/local/apache2/htdocs/bar</code>.</p>
+map requests for <code>http://example.com/games</code> to the
+path <code>/usr/local/apache2/htdocs/puzzles.html</code>.</p>
+
</dd>
-<dt>An absolute URL</dt>
+<dt>3. An absolute URL</dt>
<dd>
<pre class="prettyprint lang-config">RewriteRule "^/product/view$" "http://site2.example.com/seeproduct.html" [R]</pre>
@@ -224,6 +258,8 @@ path <code>/usr/local/apache2/htdocs/bar</code>.</p>
</dd>
</dl>
+<div class="warning">Note that <strong>1</strong> and <strong>2</strong> have exactly the same syntax. The difference between them is that in the case of <strong>1</strong>, the top level of the target path (i.e., <code>/usr/</code>) exists on the filesystem, where as in the case of <strong>2</strong>, it does not. (i.e., there's no <code>/bar/</code> as a root-level directory in the filesystem.)</div>
+
<p>The <var>Substitution</var> can also
contain <em>back-references</em> to parts of the incoming URL-path
matched by the <var>Pattern</var>. Consider the following:</p>
@@ -275,7 +311,7 @@ argument is a list of flags that modify how the match is evaluated.</p>
<p>For example, to send all requests from a particular IP range to a
different server, you could use:</p>
<pre class="prettyprint lang-config">RewriteCond "%{REMOTE_ADDR}" "^10\.2\."
-RewriteRule "(.*)" "http://intranet.example.com$1"</pre>
+RewriteRule "(.*)" "http://intranet.example.com$1"</pre>
<p>When more than
@@ -286,8 +322,8 @@ applied. For example, to deny requests that contain the word "hack" in
their query string, unless they also contain a cookie containing
the word "go", you could use:</p>
<pre class="prettyprint lang-config">RewriteCond "%{QUERY_STRING}" "hack"
-RewriteCond "%{HTTP_COOKIE}" "!go"
-RewriteRule "." "-" [F]</pre>
+RewriteCond "%{HTTP_COOKIE}" !go
+RewriteRule "." "-" [F]</pre>
<p>Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".</p>
@@ -299,7 +335,7 @@ variables <code>%1</code>, <code>%2</code>, etc. For example, this
will direct the request to a different directory depending on the
hostname used to access the site:</p>
<pre class="prettyprint lang-config">RewriteCond "%{HTTP_HOST}" "(.*)"
-RewriteRule "^/(.*)" "/sites/%1/$1"</pre>
+RewriteRule "^/(.*)" "/sites/%1/$1"</pre>
<p>If the request was for <code>http://example.com/foo/bar</code>,
then <code>%1</code> would contain <code>example.com</code>
@@ -336,8 +372,8 @@ the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">Rewrit
</div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/rewrite/intro.html" title="English">&nbsp;en&nbsp;</a> |
-<a href="../fr/rewrite/intro.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
-</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
+<a href="../fr/rewrite/intro.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
+</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html';
@@ -355,7 +391,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html';
}
})(window, document);
//--><!]]></script></div><div id="footer">
-<p class="apache">Copyright 2019 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="apache">Copyright 2024 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="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
prettyPrint();
diff --git a/docs/manual/rewrite/intro.html.fr.utf8 b/docs/manual/rewrite/intro.html.fr.utf8
index fae729a..ef66fa5 100644
--- a/docs/manual/rewrite/intro.html.fr.utf8
+++ b/docs/manual/rewrite/intro.html.fr.utf8
@@ -78,7 +78,7 @@ exactement comment chaque règle est traitée.</p>
<div class="section">
<h2><a name="regex" id="regex">Expressions rationnelles</a></h2>
-<p>mod_rewrite utilise le vocabulaire des <a href="http://pcre.org/">Expressions rationnelles compatibles Perl</a>.
+<p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> utilise le vocabulaire des <a href="http://pcre.org/">Expressions rationnelles compatibles Perl</a>.
Ce document n'a pas pour prétention d'être une référence détaillée des
expressions rationnelles. A cet effet, nous recommandons les <a href="http://pcre.org/pcre.txt">pages de manuel de PCRE</a>, la <a href="http://perldoc.perl.org/perlre.html">page de manuel des
expressions rationnelles Perl</a>, et l'ouvrage <a href="http://shop.oreilly.com/product/9780596528126.do">Mastering
@@ -105,43 +105,73 @@ expressions.</p>
<th>Exemple</th>
</tr>
-<tr><td><code>.</code></td><td>Correspond à tout caractère unique
-</td><td><code>c.t</code> correspondra à <code>cat</code>,
-<code>cot</code>, <code>cut</code>, etc.</td></tr>
-<tr><td><code>+</code></td><td>Répète le caractère de correspondance
-précédent une ou plusieurs fois</td>
-<td><code>a+</code> correspond à <code>a</code>, <code>aa</code>,
-<code>aaa</code>, etc.</td></tr>
-<tr><td><code>*</code></td><td>Répète le caractère de correspondance
-précédent zéro ou plusieurs fois</td>
-<td><code>a*</code> correspond à tout ce à quoi correspond
-<code>a+</code>, mais correspond aussi à la chaîne vide.</td></tr>
-<tr><td><code>?</code></td><td>Rend la correspondance optionnelle.</td><td>
-<code>colou?r</code> correspondra à <code>color</code> et <code>colour</code>.</td>
+<tr>
+ <td><code>.</code></td>
+ <td>Correspond à tout caractère unique</td>
+ <td><code>c.t</code> correspondra à <code>cat</code>,
+ <code>cot</code>, <code>cut</code>, etc.</td>
+</tr>
+<tr>
+ <td><code>+</code></td>
+ <td>Répète le caractère de correspondance précédent une ou plusieurs fois</td>
+ <td><code>a+</code> correspond à <code>a</code>, <code>aa</code>,
+ <code>aaa</code>, etc.</td>
+</tr>
+ <tr><td><code>*</code></td>
+ <td>Répète le caractère de correspondance
+ précédent zéro ou plusieurs fois</td>
+ <td><code>a*</code> correspond à tout ce à quoi correspond
+ <code>a+</code>, mais correspond aussi à la chaîne vide.</td>
+</tr>
+<tr>
+ <td><code>?</code></td>
+ <td>Rend la correspondance optionnelle.</td>
+ <td><code>colou?r</code> correspondra à <code>color</code> et <code>colour</code>.</td>
+</tr>
+<tr>
+ <td><code>\</code></td>
+ <td>Echappe le caractère suivant</td>
+ <td><code>\.</code> correspondra à <code>.</code> (le point) et non <em>à
+ tout caractère unique</em> comme expliqué plus haut</td>
+</tr>
+<tr>
+ <td><code>^</code></td>
+ <td>Appelé ancrage, correspond au début de la
+ chaîne</td>
+ <td><code>^a</code> correspond à une chaîne qui commence par
+ <code>a</code></td>
+</tr>
+<tr>
+ <td><code>$</code></td>
+ <td>L'autre ancrage, correspond à la fin de
+ la chaîne.</td>
+ <td><code>a$</code> correspond à une chaîne qui se termine par
+ <code>a</code>.</td>
+</tr>
+<tr>
+ <td><code>( )</code></td>
+ <td>Regroupe plusieurs caractères en une
+ seule entité, et conserve une correspondance à des fins d'utilisation
+ dans une référence arrière.</td>
+ <td><code>(ab)+</code>
+ correspond à <code>ababab</code> - à savoir, le <code>+</code>
+ s'applique au groupe.
+ Pour plus de détails sur les références arrières, voir <a href="#InternalBackRefs">ci-dessous</a>.</td>
+</tr>
+<tr>
+ <td><code>[ ]</code></td>
+ <td>Une classe de caractères - correspond à
+ un des caractères de la classe</td>
+ <td><code>c[uoa]t</code> correspond à <code>cut</code>,
+ <code>cot</code> ou <code>cat</code>.</td>
+</tr>
+<tr>
+ <td><code>[^ ]</code></td>
+ <td>Négation de la classe de caractères -
+ correspond à tout caractère ne faisant pas partie de la classe</td>
+ <td><code>c[^/]t</code> correspond à <code>cat</code> ou
+ <code>c=t</code> mais pas à <code>c/t</code></td>
</tr>
-<tr><td><code>^</code></td><td>Appelé ancrage, correspond au début de la
-chaîne</td>
-<td><code>^a</code> correspond à une chaîne qui commence par
-<code>a</code></td></tr>
-<tr><td><code>$</code></td><td>L'autre ancrage, correspond à la fin de
-la chaîne.</td>
-<td><code>a$</code> correspond à une chaîne qui se termine par
-<code>a</code>.</td></tr>
-<tr><td><code>( )</code></td><td>Regroupe plusieurs caractères en une
-seule entité, et conserve une correspondance à des fins d'utilisation
-dans une référence arrière.</td>
-<td><code>(ab)+</code>
-correspond à <code>ababab</code> - à savoir, le <code>+</code>
-s'applique au groupe.
-Pour plus de détails sur les références arrières, voir <a href="#InternalBackRefs">ci-dessous</a>.</td></tr>
-<tr><td><code>[ ]</code></td><td>Une classe de caractères - correspond à
-un des caractères de la classe</td>
-<td><code>c[uoa]t</code> correspond à <code>cut</code>,
-<code>cot</code> ou <code>cat</code>.</td></tr>
-<tr><td><code>[^ ]</code></td><td>Négation de la classe de caractères -
-correspond à tout caractère ne faisant pas partie de la classe</td>
-<td><code>c[^/]t</code> correspond à <code>cat</code> ou
-<code>c=t</code> mais pas à <code>c/t</code></td></tr>
</table>
<p>Avec <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>, le caractère <code>!</code> peut
@@ -159,15 +189,14 @@ arrières dans les expressions rationnelles</a></h3>
un des <em>modèles de conditions</em>, des références arrières
sont créées en interne et peuvent être rappelées via les chaînes
<code>$N</code> et <code>%N</code> (voir ci-dessous). Ces
- références sont disponibles lors de la création
- de la chaîne de substitution d'une directive
+ références sont disponibles lors de la
+ création de la chaîne de substitution d'une directive
<code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> ou de la
chaîne de test d'une directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>.</p>
<p>Les captures dans les modèles de directives <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> sont paradoxalement
disponibles dans toutes les directives <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> qui précèdent, car
les expressions des directives <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> sont évaluées avant
les conditions individuelles.</p>
-
<p>La figure 1 montre à quels endroits les
références arrières sont suceptibles
@@ -221,25 +250,25 @@ substituée.</p>
trois types :</p>
<dl>
-<dt>Un chemin complet du système de fichiers vers une ressource</dt>
+<dt>1. Un chemin complet du système de fichiers vers une ressource</dt>
<dd>
-<pre class="prettyprint lang-config">RewriteRule "^/jeux" "/usr/local/jeux/web"</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/games" "/usr/local/games/web/puzzles.html"</pre>
<p>Ceci peut faire correspondre une requête à toute localisation voulue de
votre système de fichiers, un peu comme la directive <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>.</p>
</dd>
-<dt>Un chemin web vers une ressource</dt>
+<dt>2. Un chemin web vers une ressource</dt>
<dd>
-<pre class="prettyprint lang-config">RewriteRule "^/foo$" "/bar"</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/games$" "/puzzles.html"</pre>
<p>Si la directive <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> a
pour valeur <code>/usr/local/apache2/htdocs</code>, cette règle va faire
-correspondre les requêtes pour <code>http://example.com/foo</code> au
-chemin <code>/usr/local/apache2/htdocs/bar</code>.</p>
+correspondre les requêtes pour <code>http://example.com/games</code> au
+chemin <code>/usr/local/apache2/htdocs/puzzles.html</code>.</p>
</dd>
-<dt>Une URL absolue</dt>
+<dt>3. Une URL absolue</dt>
<dd>
<pre class="prettyprint lang-config">RewriteRule "^/produits/vues$" "http://site2.example.com/voirproduits.html" [R]</pre>
@@ -248,6 +277,13 @@ l'URL spécifiée.</p>
</dd>
</dl>
+<div class="warning">Notez que <strong>1</strong> et <strong>2</strong>
+possèdent exactement la même syntaxe. Par contre, dans le cas de
+<strong>1</strong>, le niveau racine du chemin cible (par exemple
+<code>/usr/</code>) existe dans le système de fichiers, alors que ce n'est pas
+le cas avec <strong>2</strong> (par exemple, il n'y a pas de répertoire
+<code>/bar/</code> au niveau de la racine du système de fichiers).</div>
+
<p>La chaîne de <var>Substitution</var> peut aussi contenir des
<em>références arrières</em> vers des parties du chemin d'URL entrant
correspondant au <var>Modèle</var>. Considérons ce qui suit :</p>
@@ -300,7 +336,7 @@ correspondance est évaluée.</p>
certaine tranche d'adresses IP vers un autre serveur, vous pouvez
utiliser :</p>
<pre class="prettyprint lang-config">RewriteCond "%{REMOTE_ADDR}" "^10\.2\."
-RewriteRule "(.*)" "http://intranet.example.com$1"</pre>
+RewriteRule "(.*)" "http://intranet.example.com$1"</pre>
<p>Si vous spécifiez plus d'une directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>, ces directives
@@ -309,8 +345,8 @@ pour interdire les requêtes qui contiennent le mot "hack" dans la chaîne
de requête, sauf si elles contiennent aussi un cookie contenant le mot
"go", vous pouvez utiliser :</p>
<pre class="prettyprint lang-config">RewriteCond "%{QUERY_STRING}" "hack"
-RewriteCond "%{HTTP_COOKIE}" "!go"
-RewriteRule "." "-" [F]</pre>
+RewriteCond "%{HTTP_COOKIE}" !go
+RewriteRule "." "-" [F]</pre>
<p>Notez que le point d'exclamation indique une correspondance négative
; ainsi, la règle n'est appliquée que si le cookie ne contient pas "go"</p>
@@ -323,7 +359,7 @@ les variables <code>%1</code>, <code>%2</code>, etc... Par
exemple, ce qui suit va diriger la requête vers un répertoire différent
en fonction du nom d'hôte utilisé pour accéder au site :</p>
<pre class="prettyprint lang-config">RewriteCond "%{HTTP_HOST}" "(.*)"
-RewriteRule "^/(.*)" "/sites/%1/$1"</pre>
+RewriteRule "^/(.*)" "/sites/%1/$1"</pre>
<p>Si la requête concernait <code>http://example.com/foo/bar</code>,
alors <code>%1</code> contiendrait <code>example.com</code> et
@@ -363,7 +399,7 @@ requête est correctement mise en correspondance.</p>
<div class="bottomlang">
<p><span>Langues Disponibles: </span><a href="../en/rewrite/intro.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="../fr/rewrite/intro.html" title="Français">&nbsp;fr&nbsp;</a></p>
-</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Commentaires</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
+</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Commentaires</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html';
@@ -381,7 +417,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html';
}
})(window, document);
//--><!]]></script></div><div id="footer">
-<p class="apache">Copyright 2019 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="apache">Copyright 2024 The Apache Software Foundation.<br />Autorisé sous <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="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
prettyPrint();