diff options
Diffstat (limited to 'docs/manual/rewrite')
22 files changed, 1493 insertions, 945 deletions
diff --git a/docs/manual/rewrite/access.html.en b/docs/manual/rewrite/access.html.en index 130bef33..a59cb739 100644 --- a/docs/manual/rewrite/access.html.en +++ b/docs/manual/rewrite/access.html.en @@ -8,10 +8,13 @@ <title>Using mod_rewrite to control access - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -40,7 +43,7 @@ configuration.</div> <li><img alt="" src="../images/down.gif" /> <a href="#blocking-of-robots">Blocking of Robots</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#host-deny">Denying Hosts in a Blacklist</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#referer-deflector">Referer-based Deflector</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="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="blocked-inline-images" id="blocked-inline-images">Forbidding Image "Hotlinking"</a></h2> @@ -76,29 +79,32 @@ configuration.</div> -<div class="example"><p><code> -RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br /> -RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br /> -RewriteRule <strong>\.(gif|jpg|png)$</strong> - [F,NC] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_REFERER} !^$ +RewriteCond %{HTTP_REFERER} !www.example.com [NC] +RewriteRule \.(gif|jpg|png)$ - [F,NC] +</pre> + <p>In this second example, instead of failing the request, we display an alternate image instead.</p> -<div class="example"><p><code> -RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br /> -RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br /> -RewriteRule <strong>\.(gif|jpg|png)$</strong> /images/go-away.png [R,NC] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_REFERER} !^$ +RewriteCond %{HTTP_REFERER} !www.example.com [NC] +RewriteRule \.(gif|jpg|png)$ /images/go-away.png [R,NC] +</pre> + <p>In the third example, we redirect the request to an image on some other site.</p> -<div class="example"><p><code> -RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br /> -RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br /> -RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif [R,NC] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_REFERER} !^$ +RewriteCond %{HTTP_REFERER} !www.example.com [NC] +RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC] +</pre> + <p>Of these techniques, the last two tend to be the most effective in getting people to stop hotlinking your images, because they will @@ -113,14 +119,13 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif than redirecting that request elsewhere, this can be accomplished without the use of mod_rewrite:</p> - <div class="example"><p><code> - SetEnvIf Referer example\.com localreferer<br /> - <FilesMatch \.(jpg|png|gif)$><br /> - Order deny,allow<br /> - Deny from all<br /> - Allow from env=localreferer<br /> - </FilesMatch> - </code></p></div> + <pre class="prettyprint lang-config"> +SetEnvIf Referer example\.com localreferer +<FilesMatch \.(jpg|png|gif)$> + Require env localreferer +</FilesMatch> + </pre> + </dd> </dl> @@ -163,11 +168,12 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif range, if you are trying to block that user agent only from the particular source.</p> -<div class="example"><p><code> -RewriteCond %{HTTP_USER_AGENT} ^<strong>NameOfBadRobot</strong><br /> -RewriteCond %{REMOTE_ADDR} =<strong>123\.45\.67\.[8-9]</strong><br /> -RewriteRule ^<strong>/secret/files/</strong> - [<strong>F</strong>] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot +RewriteCond %{REMOTE_ADDR} =123\.45\.67\.[8-9] +RewriteRule ^/secret/files/ - [F] +</pre> + </dd> <dt>Discussion:</dt> @@ -177,14 +183,16 @@ RewriteRule ^<strong>/secret/files/</strong> - [<strong>F</strong>] Rather than using mod_rewrite for this, you can accomplish the same end using alternate means, as illustrated here: </p> - <div class="example"><p><code> - SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway<br /> - <Location /secret/files><br /> - Order allow,deny<br /> - Allow from all<br /> - Deny from env=goaway<br /> - </Location> - </code></p></div> + <pre class="prettyprint lang-config"> +SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway +<Location /secret/files> + <RequireAll> + Require all granted + Require not env goaway + </RequireAll> +</Location> + </pre> + <p> As noted above, this technique is trivial to circumvent, by simply modifying the <code>USER_AGENT</code> request header. If you @@ -214,13 +222,14 @@ RewriteRule ^<strong>/secret/files/</strong> - [<strong>F</strong>] <dt>Solution:</dt> <dd> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteMap hosts-deny txt:/path/to/hosts.deny<br /> -RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]<br /> -RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteMap hosts-deny txt:/path/to/hosts.deny +RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR] +RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND RewriteRule ^ - [F] -</code></p></div> +</pre> + <div class="example"><p><code> ##<br /> @@ -268,23 +277,24 @@ bsdti1.sdm.de -<br /> <p>The following ruleset uses a map file to associate each Referer with a redirection target.</p> -<div class="example"><p><code> -RewriteMap deflector txt:/path/to/deflector.map<br /> -<br /> -RewriteCond %{HTTP_REFERER} !=""<br /> -RewriteCond ${deflector:%{HTTP_REFERER}} =-<br /> -RewriteRule ^ %{HTTP_REFERER} [R,L]<br /> -<br /> -RewriteCond %{HTTP_REFERER} !=""<br /> -RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND<br /> +<pre class="prettyprint lang-config"> +RewriteMap deflector txt:/path/to/deflector.map + +RewriteCond %{HTTP_REFERER} !="" +RewriteCond ${deflector:%{HTTP_REFERER}} =- +RewriteRule ^ %{HTTP_REFERER} [R,L] + +RewriteCond %{HTTP_REFERER} !="" +RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L] -</code></p></div> +</pre> + <p>The map file lists redirection targets for each referer, or, if we just wish to redirect back to where they came from, a "-" is placed in the map:</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> ##<br /> ## deflector.map<br /> ##<br /> @@ -292,7 +302,8 @@ RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L] http://badguys.example.com/bad/index.html -<br /> http://badguys.example.com/bad/index2.html -<br /> http://badguys.example.com/bad/index3.html http://somewhere.example.com/ -</code></p></div> +</pre> + </dd> </dl> @@ -301,7 +312,28 @@ http://badguys.example.com/bad/index3.html http://somewhere.example.com/ <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/access.html" title="English"> en </a> | <a href="../fr/rewrite/access.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/access.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/access.html.fr b/docs/manual/rewrite/access.html.fr index 861e8082..238cd155 100644 --- a/docs/manual/rewrite/access.html.fr +++ b/docs/manual/rewrite/access.html.fr @@ -8,10 +8,13 @@ <title>Utiliser mod_rewrite pour le contrôle d'accès - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -41,7 +44,7 @@ copier/coller dans vos fichiers de configuration.</div> <li><img alt="" src="../images/down.gif" /> <a href="#host-deny">Rejet des clients contenus dans une liste noire</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#referer-deflector">Aiguillage basé sur l'en-tête Referer</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="vhosts.html">Serveurs virtuels</a></li><li><a href="proxy.html">Serveurs mandataires</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></ul></div> +correspondance</a></li><li><a href="vhosts.html">Serveurs virtuels</a></li><li><a href="proxy.html">Serveurs mandataires</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></ul><ul class="seealso"><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="blocked-inline-images" id="blocked-inline-images">Blocage du référencement à chaud (Hotlinking) d'images</a></h2> @@ -77,30 +80,33 @@ correspondance</a></li><li><a href="vhosts.html">Serveurs virtuels</a></li><li>< -<div class="example"><p><code> -RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br /> -RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br /> -RewriteRule <strong>\.(gif|jpg|png)$</strong> - [F,NC] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_REFERER} !^$ +RewriteCond %{HTTP_REFERER} !www.example.com [NC] +RewriteRule \.(gif|jpg|png)$ - [F,NC] +</pre> + <p>Dans le second exemple, plutôt que de rejeter la requête, nous affichons une autre image à la place.</p> -<div class="example"><p><code> -RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br /> -RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br /> -RewriteRule <strong>\.(gif|jpg|png)$</strong> /images/go-away.png [R,NC] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_REFERER} !^$ +RewriteCond %{HTTP_REFERER} !www.example.com [NC] +RewriteRule \.(gif|jpg|png)$ /images/go-away.png [R,NC] +</pre> + <p>Dans le troisième exemple, nous redirigeons la requête vers une image appartenant à un autre site.</p> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_REFERER} !^$ +RewriteCond %{HTTP_REFERER} !www.example.com [NC] +RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC] +</pre> + -<div class="example"><p><code> -RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br /> -RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br /> -RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif [R,NC] -</code></p></div> <p>De tous ces exemples, les deux derniers semblent les plus efficaces pour faire en sorte que les gens arrêtent de référencer vos images à chaud, car il ne verront pas les images @@ -115,14 +121,13 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif simplement interdire l'accès à la ressource, vous pouvez y parvenir sans utiliser mod_rewrite :</p> - <div class="example"><p><code> - SetEnvIf Referer exemple\.com localreferer<br /> - <FilesMatch \.(jpg|png|gif)$><br /> - Order deny,allow<br /> - Deny from all<br /> - Allow from env=localreferer<br /> - </FilesMatch> - </code></p></div> + <pre class="prettyprint lang-config"> +SetEnvIf Referer example\.com localreferer +<FilesMatch \.(jpg|png|gif)$> + Require env localreferer +</FilesMatch> + </pre> + </dd> </dl> @@ -151,8 +156,7 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif <p>Notez qu'il existe des méthodes d'exclusion qui n'utilisent pas mod_rewrite. Notez aussi que toute technique qui repose sur le contenu de la chaîne client <code>USER_AGENT</code> peut être - contournée très facilement car cette chaîne de caractères peut - être modifiée.</p> + contournée très facilement car cette chaîne peut être modifiée.</p> </dd> <dt>Solution :</dt> @@ -160,7 +164,7 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif <dd> <p>On utilise un jeu de règles qui spécifie le répertoire à protéger, ainsi que la chaîne client <code>USER_AGENT</code> qui - identifie le robot indésirable ou envahissant.</p> + identifie le robot malin ou envahissant.</p> <p>Dans cet exemple, nous bloquons un robot nommé <code>Vilain_Robot</code> pour le répertoire @@ -168,11 +172,12 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif seulement depuis une source particulière, vous pouvez aussi spécifier un intervalle d'adresses IP.</p> -<div class="example"><p><code> -RewriteCond %{HTTP_USER_AGENT} ^<strong>Vilain_Robot</strong><br /> -RewriteCond %{REMOTE_ADDR} =<strong>123\.45\.67\.[8-9]</strong><br /> -RewriteRule ^<strong>/secret/fichiers/</strong> - [<strong>F</strong>] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot +RewriteCond %{REMOTE_ADDR} =123\.45\.67\.[8-9] +RewriteRule ^/secret/files/ - [F] +</pre> + </dd> <dt>Discussion :</dt> @@ -182,14 +187,16 @@ RewriteRule ^<strong>/secret/fichiers/</strong> - [<strong>F</strong>] Vous pouvez cependant parvenir au même résultat sans utiliser mod_rewrite via la méthode alternative suivante : </p> - <div class="example"><p><code> - SetEnvIfNoCase User-Agent ^Vilain_Robot interdit<br /> - <Location /secret/fichiers><br /> - Order allow,deny<br /> - Allow from all<br /> - Deny from env=interdit<br /> - </Location> - </code></p></div> + <pre class="prettyprint lang-config"> +SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway +<Location /secret/files> + <RequireAll> + Require all granted + Require not env goaway + </RequireAll> +</Location> + </pre> + <p> Comme indiqué plus haut, il est aisé de contourner cette technique, simplement en modifiant le contenu de l'en-tête @@ -220,13 +227,14 @@ RewriteRule ^<strong>/secret/fichiers/</strong> - [<strong>F</strong>] <dt>Solution :</dt> <dd> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteMap hosts-deny txt:/chemin/vers/hosts.deny<br /> -RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]<br /> -RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteMap hosts-deny txt:/path/to/hosts.deny +RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR] +RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND RewriteRule ^ - [F] -</code></p></div> +</pre> + <div class="example"><p><code> ##<br /> @@ -276,24 +284,25 @@ bsdti1.sdm.de -<br /> <p>Le jeu de règles suivant utilise un fichier de correspondances pour associer chaque Referer à une cible de redirection.</p> -<div class="example"><p><code> -RewriteMap deflector txt:/chemin/vers/deflector.map<br /> -<br /> -RewriteCond %{HTTP_REFERER} !=""<br /> -RewriteCond ${deflector:%{HTTP_REFERER}} =-<br /> -RewriteRule ^ %{HTTP_REFERER} [R,L]<br /> -<br /> -RewriteCond %{HTTP_REFERER} !=""<br /> -RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND<br /> +<pre class="prettyprint lang-config"> +RewriteMap deflector txt:/path/to/deflector.map + +RewriteCond %{HTTP_REFERER} !="" +RewriteCond ${deflector:%{HTTP_REFERER}} =- +RewriteRule ^ %{HTTP_REFERER} [R,L] + +RewriteCond %{HTTP_REFERER} !="" +RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L] -</code></p></div> +</pre> + <p>Le fichier de correspondances contient les cibles de redirection associées à chaque Referer, ou, si nous voulons simplement rediriger les requêtes vers leur Referer, un "-" est inscrit dans le fichier de correspondances :</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> ##<br /> ## deflector.map<br /> ##<br /> @@ -301,7 +310,8 @@ RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L] http://www.mauvais-gars.example.com/mauvais/index.html -<br /> http://www.mauvais-gars.example.com/mauvais/index2.html -<br /> http://www.mauvais-gars.example.com/mauvais/index3.html http://quelque-part.example.com/ -</code></p></div> +</pre> + </dd> </dl> @@ -310,7 +320,28 @@ http://www.mauvais-gars.example.com/mauvais/index3.html http://quelque-part.ex <div class="bottomlang"> <p><span>Langues Disponibles: </span><a href="../en/rewrite/access.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/access.html" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/access.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/advanced.html.en b/docs/manual/rewrite/advanced.html.en index 497e3bb5..cc4d20ed 100644 --- a/docs/manual/rewrite/advanced.html.en +++ b/docs/manual/rewrite/advanced.html.en @@ -8,10 +8,13 @@ <title>Advanced Techniques with mod_rewrite - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -41,7 +44,7 @@ configuration.</div> <li><img alt="" src="../images/down.gif" /> <a href="#redirectanchors">Redirecting Anchors</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#time-dependent">Time-Dependent Rewriting</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#setenvvars">Set Environment Variables Based On URL Parts</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="sharding" id="sharding">URL-based sharding accross multiple backends</a></h2> @@ -89,13 +92,12 @@ http://physical_host_of_user1/u/user/anypath files assuming that server0 is a default server which will be used if a user has no entry in the map:</p> -<div class="example"><p><code> -RewriteEngine on<br /> -<br /> -RewriteMap users-to-hosts txt:/path/to/map.users-to-hosts<br /> -<br /> -RewriteRule ^/u/<strong>([^/]+)</strong>/?(.*) http://<strong>${users-to-hosts:$1|server0}</strong>/u/$1/$2 -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteMap users-to-hosts txt:/path/to/map.users-to-hosts +RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2 +</pre> + </dd> </dl> @@ -124,11 +126,12 @@ RewriteRule ^/u/<strong>([^/]+)</strong>/?(.*) http://<strong>${users-to-hos <dd> This is done via the following ruleset: -<div class="example"><p><code> -# This example is valid in per-directory context only<br /> -RewriteCond %{REQUEST_URI} <strong>!-U</strong><br /> +<pre class="prettyprint lang-config"> +# This example is valid in per-directory context only +RewriteCond %{REQUEST_URI} !-U RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L] -</code></p></div> +</pre> + <p>The <code>-U</code> operator determines whether the test string (in this case, <code>REQUEST_URI</code>) is a valid URL. It does @@ -165,12 +168,12 @@ RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L] <p>We'll use <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> and a list of servers to accomplish this.</p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteMap lb rnd:/path/to/serverlist.txt<br /> -<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteMap lb rnd:/path/to/serverlist.txt RewriteRule ^/(.*) http://${lb:servers}/$1 [P,L] -</code></p></div> +</pre> + <p><code>serverlist.txt</code> will contain a list of the servers:</p> @@ -221,9 +224,10 @@ featureful than anything you can cobble together using mod_rewrite.</p> URL causes the 'page' to be refreshed every time it is updated on the filesystem.</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1 -</code></p></div> +</pre> + <p>Now when we reference the URL</p> @@ -241,7 +245,7 @@ RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1 one would usually say "left as an exercise to the reader" ;-) I will provide this, too.</p> -<div class="example"><pre> +<pre class="prettyprint lang-perl"> #!/sw/bin/perl ## ## nph-refresh -- NPH/CGI script for auto refreshing pages @@ -250,61 +254,61 @@ RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1 $| = 1; # split the QUERY_STRING variable -@pairs = split(/&/, $ENV{'QUERY_STRING'}); +@pairs = split( /&/, $ENV{'QUERY_STRING'} ); foreach $pair (@pairs) { -($name, $value) = split(/=/, $pair); -$name =~ tr/A-Z/a-z/; -$name = 'QS_' . $name; -$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; -eval "\$$name = \"$value\""; + ( $name, $value ) = split( /=/, $pair ); + $name =~ tr/A-Z/a-z/; + $name = 'QS_' . $name; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + eval "\$$name = \"$value\""; } -$QS_s = 1 if ($QS_s eq ''); -$QS_n = 3600 if ($QS_n eq ''); -if ($QS_f eq '') { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; -print "&lt;b&gt;ERROR&lt;/b&gt;: No file given\n"; -exit(0); +$QS_s = 1 if ( $QS_s eq '' ); +$QS_n = 3600 if ( $QS_n eq '' ); +if ( $QS_f eq '' ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; + print "<b>ERROR</b>: No file given\n"; + exit(0); } -if (! -f $QS_f) { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; -print "&lt;b&gt;ERROR&lt;/b&gt;: File $QS_f not found\n"; -exit(0); +if ( !-f $QS_f ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; + print "<b>ERROR</b>: File $QS_f not found\n"; + exit(0); } sub print_http_headers_multipart_begin { -print "HTTP/1.0 200 OK\n"; -$bound = "ThisRandomString12345"; -print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; -&print_http_headers_multipart_next; + print "HTTP/1.0 200 OK\n"; + $bound = "ThisRandomString12345"; + print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; + &print_http_headers_multipart_next; } sub print_http_headers_multipart_next { -print "\n--$bound\n"; + print "\n--$bound\n"; } sub print_http_headers_multipart_end { -print "\n--$bound--\n"; + print "\n--$bound--\n"; } sub displayhtml { -local($buffer) = @_; -$len = length($buffer); -print "Content-type: text/html\n"; -print "Content-length: $len\n\n"; -print $buffer; + local ($buffer) = @_; + $len = length($buffer); + print "Content-type: text/html\n"; + print "Content-length: $len\n\n"; + print $buffer; } sub readfile { -local($file) = @_; -local(*FP, $size, $buffer, $bytes); -($x, $x, $x, $x, $x, $x, $x, $size) = stat($file); -$size = sprintf("%d", $size); -open(FP, "&lt;$file"); -$bytes = sysread(FP, $buffer, $size); -close(FP); -return $buffer; + local ($file) = @_; + local ( *FP, $size, $buffer, $bytes ); + ( $x, $x, $x, $x, $x, $x, $x, $size ) = stat($file); + $size = sprintf( "%d", $size ); + open( FP, "<$file" ); + $bytes = sysread( FP, $buffer, $size ); + close(FP); + return $buffer; } $buffer = &readfile($QS_f); @@ -312,30 +316,30 @@ $buffer = &readfile($QS_f); &displayhtml($buffer); sub mystat { -local($file) = $_[0]; -local($time); + local ($file) = $_[0]; + local ($time); -($x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime) = stat($file); -return $mtime; + ( $x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime ) = stat($file); + return $mtime; } $mtimeL = &mystat($QS_f); -$mtime = $mtime; -for ($n = 0; $n &lt; $QS_n; $n++) { -while (1) { - $mtime = &mystat($QS_f); - if ($mtime ne $mtimeL) { - $mtimeL = $mtime; - sleep(2); - $buffer = &readfile($QS_f); - &print_http_headers_multipart_next; - &displayhtml($buffer); - sleep(5); - $mtimeL = &mystat($QS_f); - last; +$mtime = $mtime; +for ( $n = 0 ; $n & lt ; $QS_n ; $n++ ) { + while (1) { + $mtime = &mystat($QS_f); + if ( $mtime ne $mtimeL ) { + $mtimeL = $mtime; + sleep(2); + $buffer = &readfile($QS_f); + &print_http_headers_multipart_next; + &displayhtml($buffer); + sleep(5); + $mtimeL = &mystat($QS_f); + last; + } + sleep($QS_s); } - sleep($QS_s); -} } &print_http_headers_multipart_end; @@ -343,7 +347,8 @@ while (1) { exit(0); ##EOF## -</pre></div> +</pre> + </dd> </dl> @@ -372,10 +377,11 @@ exit(0); <p>We use the following ruleset to expand the tilde URLs into the above layout.</p> -<div class="example"><p><code> -RewriteEngine on<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3 -</code></p></div> +</pre> + </dd> </dl> @@ -431,13 +437,14 @@ RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</stro <code>>STRING</code> and <code>=STRING</code> we can do time-dependent redirects:</p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700<br /> -RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900<br /> -RewriteRule ^foo\.html$ foo.day.html [L]<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700 +RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900 +RewriteRule ^foo\.html$ foo.day.html [L] RewriteRule ^foo\.html$ foo.night.html -</code></p></div> +</pre> + <p>This provides the content of <code>foo.day.html</code> under the URL <code>foo.html</code> from @@ -476,17 +483,19 @@ RewriteRule ^foo\.html$ foo.night.html <dd> <p>Use the [E] flag to set an environment variable.</p> -<div class="example"><p><code> -RewriteEngine on<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on RewriteRule ^/horse/(.*) /pony/$1 [E=<strong>rewritten:1</strong>] -</code></p></div> +</pre> + <p>Later in your ruleset you might check for this environment variable using a RewriteCond:</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteCond %{ENV:rewritten} =1 -</code></p></div> +</pre> + <p>Note that environment variables do not survive an external redirect. You might consider using the [CO] flag to set a @@ -499,7 +508,28 @@ RewriteCond %{ENV:rewritten} =1 <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/avoid.html" title="English"> en </a> | <a href="../fr/rewrite/avoid.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/advanced.html.fr b/docs/manual/rewrite/advanced.html.fr index d25fd670..dcf98b15 100644 --- a/docs/manual/rewrite/advanced.html.fr +++ b/docs/manual/rewrite/advanced.html.fr @@ -5,18 +5,21 @@ This file is generated from xml source: DO NOT EDIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --> -<title>Techniques avancées de réécriture avec mod_rewrite - Serveur Apache HTTP</title> +<title>Advanced Techniques with mod_rewrite - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> <div id="path"> -<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">Serveur HTTP</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Techniques avancées de réécriture avec mod_rewrite</h1> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">Serveur HTTP</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Advanced Techniques with mod_rewrite</h1> <div class="toplang"> <p><span>Langues Disponibles: </span><a href="../en/rewrite/avoid.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/avoid.html" title="Français"> fr </a></p> @@ -45,7 +48,7 @@ simplement les copier/coller dans votre configuration.</div> <li><img alt="" src="../images/down.gif" /> <a href="#setenvvars">Définir des variables d'environnement en fonction de certaines parties de l'URL</a></li> </ul><h3>Voir aussi</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Documentation du module</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ôler l'accès</a></li><li><a href="vhosts.html">serveurs virtuels</a></li><li><a href="proxy.html">serveurs mandataires</a></li><li><a href="rewritemap.html">Utilisation de RewriteMap</a></li><li><a href="avoid.html">Quand ne pas utiliser mod_rewrite</a></li></ul></div> +correspondance</a></li><li><a href="access.html">Contrôler l'accès</a></li><li><a href="vhosts.html">serveurs virtuels</a></li><li><a href="proxy.html">serveurs mandataires</a></li><li><a href="rewritemap.html">Utilisation de RewriteMap</a></li><li><a href="avoid.html">Quand ne pas utiliser mod_rewrite</a></li></ul><ul class="seealso"><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="sharding" id="sharding">Distribution de la charge entre plusieurs serveurs @@ -98,14 +101,12 @@ http://serveur_physique_utilisateur1/u/utilisateur/chemin serveur par défaut qui sera utilisé lorsqu'un utilisateur ne possèdera pas d'entrée dans la table de correspondances :</p> -<div class="example"><p><code> -RewriteEngine on<br /> -<br /> -RewriteMap utilisateurs-serveurs -txt:/chemin/vers/correspondances-utilisateurs-serveurs<br /> -<br /> -RewriteRule ^/u/<strong>([^/]+)</strong>/?(.*) http://<strong>${utilisateurs-serveurs:$1|server0}</strong>/u/$1/$2 -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteMap users-to-hosts txt:/path/to/map.users-to-hosts +RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2 +</pre> + </dd> </dl> @@ -133,13 +134,14 @@ RewriteRule ^/u/<strong>([^/]+)</strong>/?(.*) http://<strong>${utilisateurs <dt>Solution :</dt> <dd> - À cet effet, on utilise le jeu de règles suivant : + A cet effet, on utilise le jeu de règles suivant : -<div class="example"><p><code> -# Cet exemple n'est valable que dans un contexte de répertoire<br /> -RewriteCond %{REQUEST_URI} <strong>!-U</strong><br /> +<pre class="prettyprint lang-config"> +# Cet exemple n'est valable que dans un contexte de répertoire +RewriteCond %{REQUEST_URI} !-U RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L] -</code></p></div> +</pre> + <p>L'opérateur <code>-U</code> permet de déterminer si la chaîne de test (dans ce cas <code>REQUEST_URI</code>) est une URL valide. @@ -179,12 +181,12 @@ RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L] <p>Pour y parvenir, nous allons utiliser la directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> et une liste de serveurs.</p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteMap lb rnd:/chemin/vers/liste-serveurs.txt<br /> -<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteMap lb rnd:/path/to/serverlist.txt RewriteRule ^/(.*) http://${lb:serveurs}/$1 [P,L] -</code></p></div> +</pre> + <p><code>liste-serveurs.txt</code> contiendra la liste des serveurs :</p> @@ -237,9 +239,10 @@ plus de fonctionnalités dans ce domaine que mod_rewrite.</p> actualisée chaque fois que la ressource est mise à jour dans le système de fichiers.</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^(/[uge]/[^/]+/?.*):refresh /interne/cgi/apache/nph-refresh?f=$ -</code></p></div> +</pre> + <p>Nous appelons maintenant cette URL</p> @@ -257,7 +260,7 @@ RewriteRule ^(/[uge]/[^/]+/?.*):refresh /interne/cgi/apache/nph-refresh?f=$ écrive habituellement dans ces cas "laissé à la charge du lecteur à titre d'exercice", ;-) je vous l'offre, aussi.</p> -<div class="example"><pre> +<pre class="prettyprint lang-perl"> #!/sw/bin/perl ## ## nph-refresh -- script NPH/CGI pour l'actualisation automatique de @@ -267,61 +270,61 @@ RewriteRule ^(/[uge]/[^/]+/?.*):refresh /interne/cgi/apache/nph-refresh?f=$ $| = 1; # éclate la variable QUERY_STRING -@pairs = split(/&/, $ENV{'QUERY_STRING'}); +@pairs = split( /&/, $ENV{'QUERY_STRING'} ); foreach $pair (@pairs) { -($name, $value) = split(/=/, $pair); -$name =~ tr/A-Z/a-z/; -$name = 'QS_' . $name; -$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; -eval "\$$name = \"$value\""; + ( $name, $value ) = split( /=/, $pair ); + $name =~ tr/A-Z/a-z/; + $name = 'QS_' . $name; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + eval "\$$name = \"$value\""; } -$QS_s = 1 if ($QS_s eq ''); -$QS_n = 3600 if ($QS_n eq ''); -if ($QS_f eq '') { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; -print "&lt;b&gt;ERREUR&lt;/b&gt;: Aucun fichier fourni\n"; -exit(0); +$QS_s = 1 if ( $QS_s eq '' ); +$QS_n = 3600 if ( $QS_n eq '' ); +if ( $QS_f eq '' ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; + print "<b>ERROR</b>: No file given\n"; + exit(0); } -if (! -f $QS_f) { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; -print "&lt;b&gt;ERREUR&lt;/b&gt;: Fichier $QS_f non trouvé\n"; -exit(0); +if ( !-f $QS_f ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; + print "<b>ERROR</b>: File $QS_f not found\n"; + exit(0); } sub print_http_headers_multipart_begin { -print "HTTP/1.0 200 OK\n"; -$bound = "ThisRandomString12345"; -print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; -&print_http_headers_multipart_next; + print "HTTP/1.0 200 OK\n"; + $bound = "ThisRandomString12345"; + print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; + &print_http_headers_multipart_next; } sub print_http_headers_multipart_next { -print "\n--$bound\n"; + print "\n--$bound\n"; } sub print_http_headers_multipart_end { -print "\n--$bound--\n"; + print "\n--$bound--\n"; } sub displayhtml { -local($buffer) = @_; -$len = length($buffer); -print "Content-type: text/html\n"; -print "Content-length: $len\n\n"; -print $buffer; + local ($buffer) = @_; + $len = length($buffer); + print "Content-type: text/html\n"; + print "Content-length: $len\n\n"; + print $buffer; } sub readfile { -local($file) = @_; -local(*FP, $size, $buffer, $bytes); -($x, $x, $x, $x, $x, $x, $x, $size) = stat($file); -$size = sprintf("%d", $size); -open(FP, "&lt;$file"); -$bytes = sysread(FP, $buffer, $size); -close(FP); -return $buffer; + local ($file) = @_; + local ( *FP, $size, $buffer, $bytes ); + ( $x, $x, $x, $x, $x, $x, $x, $size ) = stat($file); + $size = sprintf( "%d", $size ); + open( FP, "<$file" ); + $bytes = sysread( FP, $buffer, $size ); + close(FP); + return $buffer; } $buffer = &readfile($QS_f); @@ -329,30 +332,30 @@ $buffer = &readfile($QS_f); &displayhtml($buffer); sub mystat { -local($file) = $_[0]; -local($time); + local ($file) = $_[0]; + local ($time); -($x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime) = stat($file); -return $mtime; + ( $x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime ) = stat($file); + return $mtime; } $mtimeL = &mystat($QS_f); -$mtime = $mtime; -for ($n = 0; $n &lt; $QS_n; $n++) { -while (1) { - $mtime = &mystat($QS_f); - if ($mtime ne $mtimeL) { - $mtimeL = $mtime; - sleep(2); - $buffer = &readfile($QS_f); - &print_http_headers_multipart_next; - &displayhtml($buffer); - sleep(5); - $mtimeL = &mystat($QS_f); - last; +$mtime = $mtime; +for ( $n = 0 ; $n & lt ; $QS_n ; $n++ ) { + while (1) { + $mtime = &mystat($QS_f); + if ( $mtime ne $mtimeL ) { + $mtimeL = $mtime; + sleep(2); + $buffer = &readfile($QS_f); + &print_http_headers_multipart_next; + &displayhtml($buffer); + sleep(5); + $mtimeL = &mystat($QS_f); + last; + } + sleep($QS_s); } - sleep($QS_s); -} } &print_http_headers_multipart_end; @@ -360,7 +363,8 @@ while (1) { exit(0); ##EOF## -</pre></div> +</pre> + </dd> </dl> @@ -391,10 +395,11 @@ exit(0); <p>On utilise le jeu de règles suivant pour développer les URLs avec tilde selon l'organisation structurée précédente.</p> -<div class="example"><p><code> -RewriteEngine on<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3 -</code></p></div> +</pre> + </dd> </dl> @@ -453,13 +458,13 @@ RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</stro permettent d'effectuer des redirections dépendant de l'heure :</p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700<br /> -RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900<br /> -RewriteRule ^foo\.html$ foo.jour.html [L]<br /> -RewriteRule ^foo\.html$ foo.nuit.html -</code></p></div> +<pre class="prettyprint lang-config"> ++RewriteEngine on ++RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700 ++RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900 ++RewriteRule ^foo\.html$ foo.day.html [L] +</pre> + <p>Avec cet exemple, l'URL <code>foo.html</code> renvoie le contenu de <code>foo.jour.html</code> durant le @@ -472,7 +477,8 @@ RewriteRule ^foo\.html$ foo.nuit.html la fenêtre de temps configurée. On peut utiliser <code class="module"><a href="../mod/mod_expires.html">mod_expires</a></code> pour contourner ce problème. Il est cependant bien plus commode de servir un contenu dynamique, et - de le personnaliser en fonction de l'heure du jour.</div> </dd> + de le personnaliser en fonction de l'heure du jour.</div> + </dd> </dl> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> @@ -500,18 +506,20 @@ RewriteRule ^foo\.html$ foo.nuit.html <p>Utiliser le drapeau [E] pour définir une variable d'environnement.</p> -<div class="example"><p><code> -RewriteEngine on<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on RewriteRule ^/cheval/(.*) /poney/$1 [E=<strong>rewritten:1</strong>] -</code></p></div> +</pre> + <p>Plus loin dans votre jeu de règles, vous pouvez vérifier le contenu de cette variable d'environnement via une directive RewriteCond :</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteCond %{ENV:rewritten} =1 -</code></p></div> +</pre> + </dd> </dl> @@ -520,7 +528,28 @@ RewriteCond %{ENV:rewritten} =1 <div class="bottomlang"> <p><span>Langues Disponibles: </span><a href="../en/rewrite/avoid.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/avoid.html" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/avoid.html.en b/docs/manual/rewrite/avoid.html.en index bfe4b3a0..1ef3f7c2 100644 --- a/docs/manual/rewrite/avoid.html.en +++ b/docs/manual/rewrite/avoid.html.en @@ -8,10 +8,13 @@ <title>When not to use mod_rewrite - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -53,7 +56,7 @@ files to work with, you may need to resort to <li><img alt="" src="../images/down.gif" /> <a href="#vhosts">Virtual Hosting</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#proxy">Simple Proxying</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#setenv">Environment Variable Testing</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li></ul></div> +</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="redirect" id="redirect">Simple Redirection</a></h2> @@ -81,25 +84,24 @@ and <code>/one/three/four.html</code>.</p> <p>To redirect URLs under <code>/one</code> to <code>http://one.example.com</code>, do the following:</p> -<div class="example"><p><code> -Redirect /one/ http://one.example.com/ -</code></p></div> +<pre class="prettyprint lang-config">Redirect /one/ http://one.example.com/</pre> + <p>To redirect <code>http</code> URLs to <code>https</code>, do the following:</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> <VirtualHost *:80> -ServerName www.example.com<br /> -Redirect / https://www.example.com/<br /> + ServerName www.example.com + Redirect / https://www.example.com/ </VirtualHost > -<br /> + <VirtualHost *:443> -ServerName www.example.com<br /> -<br /> -# ... SSL configuration goes here<br /> + ServerName www.example.com + # ... SSL configuration goes here </VirtualHost > -</code></p></div> +</pre> + <p>The use of <code>RewriteRule</code> to perform this task may be appropriate if there are other <code>RewriteRule</code> directives in @@ -123,9 +125,8 @@ is possible to perform this mapping with <code>mod_rewrite</code>, <code>Alias</code> is the preferred method, for reasons of simplicity and performance.</p> -<div class="example"><h3>Using Alias</h3><p><code> -Alias /cats /var/www/virtualhosts/felines/htdocs -</code></p></div> +<div class="example"><h3>Using Alias</h3><pre class="prettyprint lang-config">Alias /cats /var/www/virtualhosts/felines/htdocs</pre> +</div> <p> The use of <code>mod_rewrite</code> to perform this mapping may be @@ -165,25 +166,28 @@ seems like the right approach.</p> <p><code>RewriteRule</code> provides the <a href="flags.html#flag_p">[P]</a> flag to pass rewritten URIs through <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>.</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P] -</code></p></div> +</pre> + <p>However, in many cases, when there is no actual pattern matching -meeded, as in the example shown above, the <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code> directive is a better choice. +needed, as in the example shown above, the <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code> directive is a better choice. The example here could be rendered as:</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> ProxyPass /images/ http://imageserver.local/images/ -</code></p></div> +</pre> + <p>Note that whether you use <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> or <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code>, you'll still need to use the <code class="directive"><a href="../mod/mod_proxy.html#proxypassreverse">ProxyPassReverse</a></code> directive to catch redirects issued from the back-end server:</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> ProxyPassReverse /images/ http://imageserver.local/images/ -</code></p></div> +</pre> + <p>You may need to use <code>RewriteRule</code> instead when there are other <code>RewriteRule</code>s in effect in the same scope, as a @@ -196,7 +200,7 @@ accomplish.</p> <h2><a name="setenv" id="setenv">Environment Variable Testing</a></h2> <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> is frequently used to take a particular -action based on the presence or absense of a particular environment +action based on the presence or absence of a particular environment variable or request header. This can be done more efficiently using the <code class="directive"><a href="../mod/core.html#if"><If></a></code>.</p> @@ -205,11 +209,12 @@ variable or request header. This can be done more efficiently using the hostname, such as <code>www.example.com</code> instead of <code>example.com</code>. This can be done using the <code class="directive"><a href="../mod/core.html#if"><If></a></code> directive, as shown here:</p> -<div class="example"><p><code> -<If "$req{Host} != 'www.example.com'"><br /> -RedirectMatch (.*) http://www.example.com$1<br /> +<pre class="prettyprint lang-config"> +<If "req('Host') != 'www.example.com'"> + Redirect / http://www.example.com/ </If> -</code></p></div> +</pre> + <p>This technique can be used to take actions based on any request header, response header, or environment variable, replacing @@ -223,7 +228,28 @@ use in <If> sections, and in certain other directives.</p> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/avoid.html" title="English"> en </a> | <a href="../fr/rewrite/avoid.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/avoid.html.fr b/docs/manual/rewrite/avoid.html.fr index 7e18617f..6c69284d 100644 --- a/docs/manual/rewrite/avoid.html.fr +++ b/docs/manual/rewrite/avoid.html.fr @@ -8,10 +8,13 @@ <title>Quand ne pas utiliser mod_rewrite - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -55,7 +58,7 @@ vous tourner vers <code class="module"><a href="../mod/mod_rewrite.html">mod_rew <li><img alt="" src="../images/down.gif" /> <a href="#proxy">Mandat simple</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#setenv">Test de variables d'environnement</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">Serveurs mandataires</a></li><li><a href="rewritemap.html">Utilisation de RewriteMap</a></li><li><a href="advanced.html">Techniques avancées</a></li></ul></div> +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">Serveurs mandataires</a></li><li><a href="rewritemap.html">Utilisation de RewriteMap</a></li><li><a href="advanced.html">Techniques avancées</a></li></ul><ul class="seealso"><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="redirect" id="redirect">Redirection simple</a></h2> @@ -88,25 +91,24 @@ rediriger toutes les URLs de niveaux inférieurs comme <p>Pour rediriger les URLs sous <code>/un</code> vers <code>http://un.example.com/</code>, utilisez cette définition :</p> -<div class="example"><p><code> -Redirect /un/ http://un.example.com/ -</code></p></div> +<pre class="prettyprint lang-config">Redirect /one/ http://one.example.com/</pre> + <p>Pour rediriger les URLs <code>http</code> vers <code>https</code>, utilisez cette définition :</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> <VirtualHost *:80> -ServerName www.example.com<br /> -Redirect / https://www.example.com/<br /> +ServerName www.example.com +Redirect / https://www.example.com/ </VirtualHost > -<br /> + <VirtualHost *:443> -ServerName www.example.com<br /> -<br /> -# ... insérer ici la configuration SSL<br /> +ServerName www.example.com +# ... insérer ici la configuration SSL </VirtualHost > -</code></p></div> +</pre> + <p>L'utilisation de la directive <code>RewriteRule</code> pour accomplir cette tâche peut se justifier s'il existe d'autres directives @@ -132,9 +134,9 @@ possible d'effectuer cette mise en correspondance avec <code>mod_rewrite</code>, il est préférable d'utiliser la directive <code>Alias</code> pour des raisons de simplicité et de performances.</p> -<div class="example"><h3>Utilisation de la directive Alias</h3><p><code> -Alias /chats /var/www/virtualhosts/felin/htdocs -</code></p></div> +<div class="example"><h3>Utilisation de la directive Alias</h3><pre class="prettyprint lang-config">Alias /cats +/var/www/virtualhosts/felines/htdocs</pre> +</div> <p> Pour effectuer cette mise en correspondance, <code>mod_rewrite</code> @@ -164,7 +166,7 @@ créer un grand nombre de serveurs virtuels dynamiquement.</p> <p>L'utilisation de <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> pour la création de serveurs virtuels peut se révéler appropriée si votre service d'hébergement ne vous permet pas d'accéder aux fichiers de configuration -du serveur, et que vous vous trouvez par conséquent obligé de passer par les +du serveur, et que vous soyez par conséquent obligé de passer par les fichiers <code>.htaccess</code>.</p> <p>Voir le document <a href="vhosts.html">création de serveurs virtuels @@ -178,26 +180,29 @@ cela semble être tout de même la meilleure approche.</p> <p>La directive <code>RewriteRule</code> fournit le drapeau <a href="flags.html#flag_p">[P]</a> qui permet de faire passer les URIs réécrits par <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>.</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/?images(.*) http://serveur-images.local/images$1 [P] -</code></p></div> +</pre> + <p>Cependant, dans les nombreux cas où aucune correspondance au modèle n'est vraiment nécessaire, comme dans l'exemple ci-dessus, il est préférable d'utiliser la directive <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code>. L'exemple précédent pourrait être remplacé par :</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> ProxyPass /images/ http://serveur-images.local/images/ -</code></p></div> +</pre> + <p>Que vous utilisiez <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> ou <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code>, vous devrez dans tous les cas utiliser aussi la directive <code class="directive"><a href="../mod/mod_proxy.html#proxypassreverse">ProxyPassReverse</a></code> pour intercepter les redirections en provenance du serveur d'arrière-plan :</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> ProxyPassReverse /images/ http://serveur-images.local/images/ -</code></p></div> +</pre> + <p>Vous devrez cependant tout de même utiliser <code>RewriteRule</code> lorsque d'autres <code>RewriteRule</code>s se trouvent dans la même portée, @@ -220,14 +225,15 @@ d'hôte canonique, tel que <code>www.example.com</code> au lieu de directive <code class="directive"><a href="../mod/core.html#if"><If></a></code> comme suit :</p> -<div class="example"><p><code> -<If "$req{Host} != 'www.example.com'"><br /> -RedirectMatch (.*) http://www.example.com$1<br /> +<pre class="prettyprint lang-config"> +<If "req('Host') != 'www.example.com'"> + Redirect / http://www.example.com </If> -</code></p></div> +</pre> + -<p>On peut utiliser cette technique dans de nombreux scénarios courants -en remplacement de <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> pour effectuer des actions +<p>On peut utiliser cette technique dans de nombreux scénarios courant +pour remplacer <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> pour effectuer des actions en fonction d'en-têtes de requêtes ou de réponses, ou de variables d'environnement.</p> @@ -240,7 +246,28 @@ ainsi que dans certaines directives.</p> <div class="bottomlang"> <p><span>Langues Disponibles: </span><a href="../en/rewrite/avoid.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/avoid.html" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/flags.html.en b/docs/manual/rewrite/flags.html.en index bfa09528..ecb2e93d 100644 --- a/docs/manual/rewrite/flags.html.en +++ b/docs/manual/rewrite/flags.html.en @@ -8,10 +8,13 @@ <title>RewriteRule Flags - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -48,7 +51,7 @@ providing detailed explanations and examples.</p> <li><img alt="" src="../images/down.gif" /> <a href="#flag_r">R|redirect</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#flag_s">S|skip</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#flag_t">T|type</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="introduction" id="introduction">Introduction</a></h2> @@ -56,9 +59,8 @@ providing detailed explanations and examples.</p> its behavior modified by one or more flags. Flags are included in square brackets at the end of the rule, and multiple flags are separated by commas.</p> -<div class="example"><p><code> -RewriteRule pattern target [Flag1,Flag2,Flag3] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule pattern target [Flag1,Flag2,Flag3]</pre> + <p>The flags all have a short form, such as <code>CO</code>, as well as a longer form, such as <code>cookie</code>. Some flags take one or more @@ -88,9 +90,8 @@ so backreferences will be unescaped at the time they are applied. Using the B flag, non-alphanumeric characters in backreferences will be escaped. For example, consider the rule:</p> -<div class="example"><p><code> -RewriteRule ^search/(.*)$ /search.php?term=$1 -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule ^search/(.*)$ /search.php?term=$1</pre> + <p>Given a search term of 'x & y/z', a browser will encode it as 'x%20%26%20y%2Fz', making the request 'search/x%20%26%20y%2Fz'. Without the B @@ -174,10 +175,11 @@ browsers that support this feature.</dd> <p>Several examples are offered here:</p> -<div class="example"><p><code> -RewriteEngine On<br /> +<pre class="prettyprint lang-config"> +RewriteEngine On RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.com:1440:/] -</code></p></div> +</pre> + <p>In the example give, the rule doesn't rewrite the request. The "-" rewrite target tells mod_rewrite to pass the request @@ -262,10 +264,11 @@ value of '1' if the requested URI is an image file. Then, that environment variable is used to exclude those requests from the access log.</p> -<div class="example"><p><code> -RewriteRule \.(png|gif|jpg) - [E=image:1]<br /> +<pre class="prettyprint lang-config"> +RewriteRule \.(png|gif|jpg)$ - [E=image:1] CustomLog logs/access_log combined env=!image -</code></p></div> +</pre> + <p>Note that this same effect can be obtained using <code class="directive"><a href="../mod/mod_setenvif.html#setenvif">SetEnvIf</a></code>. This technique is offered as an example, not as a recommendation.</p> @@ -289,9 +292,8 @@ allows more flexibility in assigning a Forbidden status.</p> <p>The following rule will forbid <code>.exe</code> files from being downloaded from your server.</p> -<div class="example"><p><code> -RewriteRule \.exe - [F] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule \.exe - [F]</pre> + <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 @@ -310,9 +312,8 @@ longer available.</p> <p>As with the [F] flag, you will typically use the "-" syntax for the rewrite target when using the [G] flag:</p> -<div class="example"><p><code> -RewriteRule oldproduct - [G,NC] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule oldproduct - [G,NC]</pre> + <p>When using [G], an [L] is implied - that is, the response is returned immediately, and no further rules are evaluated.</p> @@ -324,9 +325,8 @@ immediately, and no further rules are evaluated.</p> handler. For example, one might use this to force all files without a file extension to be parsed by the php handler:</p> -<div class="example"><p><code> -RewriteRule !\. - [H=application/x-httpd-php] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule !\. - [H=application/x-httpd-php]</pre> + <p> The regular expression above - <code>!\.</code> - will match any request @@ -338,9 +338,10 @@ For example, the following snippet used in per-server context allows <code>.php</code> files to be <em>displayed</em> by <code>mod_php</code> if they are requested with the <code>.phps</code> extension:</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source] -</code></p></div> +</pre> + <p>The regular expression above - <code>^(/source/.+\.php)s$</code> - will match any request that starts with <code>/source/</code> followed by 1 or @@ -387,11 +388,12 @@ redirects.</p> argument to <code>index.php</code>, however, the <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> ensures that if the request is already for <code>index.php</code>, the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> will be skipped.</p> -<div class="example"><p><code> -RewriteBase /<br /> -RewriteCond %{REQUEST_URI} !=/index.php<br /> +<pre class="prettyprint lang-config"> +RewriteBase / +RewriteCond %{REQUEST_URI} !=/index.php RewriteRule ^(.*) /index.php?req=$1 [L,PT] -</code></p></div> +</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_n" id="flag_n">N|next</a></h2> @@ -407,9 +409,8 @@ will replace A with B everywhere in a request, and will continue doing so until there are no more As to be replaced. </p> -<div class="example"><p><code> -RewriteRule (.*)A(.*) $1B$2 [N] -</code></p></div> +<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 @@ -428,9 +429,8 @@ to your dedicated image server. The match is case-insensitive, so that <code>.jpg</code> and <code>.JPG</code> files are both acceptable, for example.</p> -<div class="example"><p><code> -RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]</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_ne" id="flag_ne">NE|noescape</a></h2> @@ -439,9 +439,8 @@ RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC] equivalent. Using the [NE] flag prevents that from happening. </p> -<div class="example"><p><code> -RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]</pre> + <p> The above example will redirect <code>/anchor/xyz</code> to @@ -482,9 +481,8 @@ requests. example, if you wanted all image requests to be handled by a back-end image server, you might do something like the following:</p> -<div class="example"><p><code> -RewriteRule /(.*)\.(jpg|gif|png) http://images.example.com/$1.$2 [P] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule /(.*)\.(jpg|gif|png)$ http://images.example.com/$1.$2 [P]</pre> + <p>Use of the [P] flag implies [L] - that is, the request is immediately pushed through the proxy, and any following rules will not be @@ -507,6 +505,15 @@ and hostname part of the URL is either fixed, or does not allow the client undue influence.</p> </div> +<div class="warning"> +<h3>Performance warning</h3> +<p>Using this flag triggers the use of <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>, without handling of persistent connections. This +means the performance of your proxy will be better if you set it up with <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code> or +<code class="directive"><a href="../mod/mod_proxy.html#proxypassmatch">ProxyPassMatch</a></code></p> +<p>This is because this flag triggers the use of the default worker, which does not handle connection pooling.</p> +<p>Avoid using this flag and prefer those directives, whenever you can.</p> +</div> + <p>Note: <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code> must be enabled in order to use this flag.</p> @@ -531,10 +538,11 @@ use the [PT] flag to ensure that the <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> is evaluated. </p> -<div class="example"><p><code> -Alias /icons /usr/local/apache/icons<br /> -RewriteRule /pics/(.+)\.jpg /icons/$1.gif [PT] -</code></p></div> +<pre class="prettyprint lang-config"> +Alias /icons /usr/local/apache/icons +RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT] +</pre> + <p> Omission of the [PT] flag in this case will cause the Alias to be @@ -563,9 +571,8 @@ Using the [QSA] flag causes the query strings to be combined. <p>Consider the following rule:</p> -<div class="example"><p><code> -RewriteRule /pages/(.+) /page.php?page=$1 [QSA] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule /pages/(.+) /page.php?page=$1 [QSA]</pre> + <p>With the [QSA] flag, a request for <code>/pages/123?one=two</code> will be mapped to <code>/page.php?page=123&one=two</code>. Without the [QSA] @@ -611,10 +618,8 @@ will be used to generate the URL sent with the redirect. <em>Any</em> valid HTTP response status code may be specified, using the syntax [R=305], with a 302 status code being used by default if none is specified. The status code specified need not -necessarily be a redirect (3xx) status code. -</p> - -<p>If a status code is outside the redirect range (300-399) then the +necessarily be a redirect (3xx) status code. However, +if a status code is outside the redirect range (300-399) then the substitution string is dropped entirely, and rewriting is stopped as if the <code>L</code> were used.</p> @@ -633,21 +638,24 @@ URI in request' warnings. </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></h2> -<p>The [S] flag is used to skip rules that you don't want to run. 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 actual file.</p> - -<div class="example"><p><code> -# Is the request for a non-existent file?<br /> -RewriteCond %{REQUEST_FILENAME} !-f<br /> -RewriteCond %{REQUEST_FILENAME} !-d<br /> -# If so, skip these two RewriteRules<br /> -RewriteRule .? - [S=2]<br /> -<br /> -RewriteRule (.*\.gif) images.php?$1<br /> +<p>The [S] flag is used to skip rules that you don't want to run. The +syntax of the skip flag is [S=<em>N</em>], where <em>N</em> signifies +the number of rules to skip. 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 actual file.</p> + +<pre class="prettyprint lang-config"> +# Is the request for a non-existent file? +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +# If so, skip these two RewriteRules +RewriteRule .? - [S=2] + +RewriteRule (.*\.gif) images.php?$1 RewriteRule (.*\.html) docs.php?$1 -</code></p></div> +</pre> + <p>This technique is useful because a <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> only applies to the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> immediately @@ -657,26 +665,23 @@ negate those conditions and add a <code>RewriteRule</code> with a [Skip] flag. Y use this to make pseudo if-then-else constructs: The last rule of the then-clause becomes <code>skip=N</code>, where N is the number of rules in the else-clause:</p> -<div class="example"><p><code> -# Does the file exist?<br /> -RewriteCond %{REQUEST_FILENAME} !-f<br /> -RewriteCond %{REQUEST_FILENAME} !-d<br /> -# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.<br /> -RewriteRule .? - [S=3]<br /> -<br /> +<pre class="prettyprint lang-config"> +# Does the file exist? +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza. +RewriteRule .? - [S=3] + # IF the file exists, then: -<span class="indent"> - RewriteRule (.*\.gif) images.php?$1<br /> - RewriteRule (.*\.html) docs.php?$1<br /> - # Skip past the "else" stanza.<br /> - RewriteRule .? - [S=1]<br /> -</span> + RewriteRule (.*\.gif) images.php?$1 + RewriteRule (.*\.html) docs.php?$1 + # Skip past the "else" stanza. + RewriteRule .? - [S=1] # ELSE... -<span class="indent"> - RewriteRule (.*) 404.php?file=$1<br /> -</span> + RewriteRule (.*) 404.php?file=$1 # END -</code></p></div> +</pre> + <p>It is probably easier to accomplish this kind of configuration using the <code class="directive"><If></code>, <code class="directive"><ElseIf></code>, and <code class="directive"><Else></code> directives instead.</p> @@ -690,19 +695,21 @@ sent. This has the same effect as the <code class="directive"><a href="../mod/mo <p>For example, you might use the following technique to serve Perl source code as plain text, if requested in a particular way:</p> -<div class="example"><p><code> -# Serve .pl files as plain text<br /> +<pre class="prettyprint lang-config"> +# Serve .pl files as plain text RewriteRule \.pl$ - [T=text/plain] -</code></p></div> +</pre> + <p>Or, perhaps, if you have a camera that produces jpeg images without file extensions, you could force those images to be served with the correct MIME type by virtue of their file names:</p> -<div class="example"><p><code> -# Files with 'IMG' in the name are jpg images.<br /> +<pre class="prettyprint lang-config"> +# Files with 'IMG' in the name are jpg images. RewriteRule IMG - [T=image/jpg] -</code></p></div> +</pre> + <p>Please note that this is a trivial example, and could be better done using <code class="directive"><a href="../mod/core.html#filesmatch"><FilesMatch></a></code> @@ -722,7 +729,28 @@ The <code>L</code> flag can be useful in this context to end the <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/flags.html" title="English"> en </a> | <a href="../fr/rewrite/flags.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/flags.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/flags.html.fr b/docs/manual/rewrite/flags.html.fr index 022bee4d..c3bdc409 100644 --- a/docs/manual/rewrite/flags.html.fr +++ b/docs/manual/rewrite/flags.html.fr @@ -8,10 +8,13 @@ <title>Les drapeaux de réécriture - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -21,8 +24,6 @@ <p><span>Langues Disponibles: </span><a href="../en/rewrite/flags.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/flags.html" title="Français"> fr </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>Ce document décrit les drapeaux disponibles dans la directive <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>, en fournissant @@ -51,16 +52,15 @@ des explications détaillées et des exemples.</p> <li><img alt="" src="../images/down.gif" /> <a href="#flag_s">S|skip</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#flag_t">T|type</a></li> </ul><h3>Voir aussi</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Documentation du module</a></li><li><a href="intro.html">Introduction à mod_rewrite</a></li><li><a href="remapping.html">Redirection and 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></ul></div> +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></ul><ul class="seealso"><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="introduction" id="introduction">Introduction</a></h2> <p>Le comportement d'une directive <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> peut être modifié par un ou plusieurs drapeaux. Les drapeaux sont situés en fin de règle, entourés de crochets, et séparés le cas échéant par des virgules.</p> -<div class="example"><p><code> -RewriteRule modèle cible [drapeau1,drapeau2,drapeau3] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule pattern target [Flag1,Flag2,Flag3]</pre> + <p>Les drapeaux ont tous une forme courte, comme <code>CO</code>, ainsi qu'une forme longue, comme <code>cookie</code>. Certains drapeaux @@ -94,9 +94,8 @@ ces dernières sont appliquées. Avec le drapeau B, les caractères non-alphanumériques des références arrières seront échappés. Considérons par exemple cette règle :</p> -<div class="example"><p><code> -RewriteRule ^search/(.*)$ /search.php?term=$1 -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule ^search/(.*)$ /search.php?term=$1</pre> + <p>Soit le terme de recherche 'x & y/z' ; un navigateur va le coder en 'x%20%26%20y%2Fz', transformant la requête en @@ -189,10 +188,11 @@ fonctionnalité.</dd> <p>Voici un exemple :</p> -<div class="example"><p><code> -RewriteEngine On<br /> +<pre class="prettyprint lang-config"> +RewriteEngine On RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.org:1440:/] -</code></p></div> +</pre> + <p>Dans l'exemple ci-dessus, la règle ne réécrit pas la requête. La cible de réécriture "-" @@ -309,9 +309,8 @@ Forbidden.</p> <p>La règle suivante va interdire la téléchargement de fichiers <code>.exe</code> depuis votre serveur.</p> -<div class="example"><p><code> -RewriteRule \.exe - [F] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule \.exe - [F]</pre> + <p>Cet exemple utilise la syntaxe "-" pour la cible de réécriture, ce qui signifie que l'URI de la requête n'est pas modifié. Il n'y a aucune @@ -331,9 +330,8 @@ disponible auparavant ne l'est plus actuellement.</p> <p>Comme dans le cas du drapeau [F], on utilise en général la syntaxe "-" pour la cible de réécriture lorsqu'on utilise le drapeau [G] :</p> -<div class="example"><p><code> -RewriteRule ancienne-ressource - [G,NC] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule oldproduct - [G,NC]</pre> + <p>Lorsqu'on utilise [G], [L] est implicite - c'est à dire que la réponse est renvoyée immédiatement, et aucune autre règle n'est évaluée.</p> @@ -346,9 +344,9 @@ spécifié. Par exemple, on peut utiliser ce drapeau pour forcer l'interprétation de tous les fichiers sans extension par le gestionnaire php :</p> -<div class="example"><p><code> -RewriteRule !\. - [H=application/x-httpd-php] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule !\. - +[H=application/x-httpd-php]</pre> + <p> L'expression rationnelle ci-dessus - <code>!\.</code> - correspond à @@ -361,9 +359,10 @@ faire en sorte que les fichiers <code>.php</code> soient <em>affichés</em> par <code>mod_php</code> dans le cas où ils font l'objet d'une requête avec l'extension <code>.phps</code> :</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source] -</code></p></div> +</pre> + <p>L'expression rationnelle ci-dessus - @@ -416,11 +415,12 @@ de requête en argument à <code>index.php</code> ; cependant, la directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> permet de s'assurer que si la requête concerne déjà <code>index.php</code>, la directive <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> sera sautée.</p> -<div class="example"><p><code> -RewriteBase /<br /> -RewriteCond %{REQUEST_URI} !=/index.php<br /> +<pre class="prettyprint lang-config"> +RewriteBase / +RewriteCond %{REQUEST_URI} !=/index.php RewriteRule ^(.*) /index.php?req=$1 [L,PT] -</code></p></div> +</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_n" id="flag_n">N|next</a></h2> @@ -437,9 +437,8 @@ suivant, chaque occurence de A sera remplacée par B dans la requête, et ceci jusqu'il n'y ait plus de A à remplacer. </p> -<div class="example"><p><code> -RewriteRule (.*)A(.*) $1B$2 [N] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule (.*)A(.*) $1B$2 [N]</pre> + <p>Vous pouvez vous représenter ce traitement comme une boucle <code>while</code> : tant que le modèle de la règle correspond (c'est à @@ -460,9 +459,8 @@ transmise par Apache à votre serveur d'images dédié. La correspondance est insensible à la casse, si bien que par exemple, <code>.jpg</code> aussi bien que <code>.JPG</code> seront acceptés.</p> -<div class="example"><p><code> -RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]</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_ne" id="flag_ne">NE|noescape</a></h2> @@ -471,9 +469,8 @@ RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC] hexadécimal. Le drapeau [NE] permet d'éviter cette conversion. </p> -<div class="example"><p><code> -RewriteRule ^/ancre/(.+) /grosse-page.html#$1 [NE,R] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]</pre> + <p> Dans l'exemple ci-dessus, <code>/anchor/xyz</code> est réécrit en @@ -518,9 +515,8 @@ mandataire. Par exemple, si vous voulez que toutes les requêtes d'images soient traitées par un serveur d'images annexe, vous pouvez utiliser une règle de ce style :</p> -<div class="example"><p><code> -RewriteRule /(.*)\.(jpg|gif|png) http://images.example.com/$1.$2 [P] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule /(.*)\.(jpg|gif|png)$ http://images.example.com/$1.$2 [P]</pre> + <p>L'utilisation du drapeau [P] provoque aussi l'effet du drapeau [L] - autrement dit, la requête est immédiatement envoyée au mandataire, et @@ -546,6 +542,16 @@ local.</p> fixe, ou ne permette pas au client de l'influencer induement.</p> </div> +<div class="warning"> + <h3>Avertissement au sujet des performances</h3> + <p>Utiliser ce drapeau fait intervenir <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code> sans la gestion des connexions + persistantes, ce qui signifie que vous obtiendrez des performances meilleurs si vous utilisez + <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code> ou <code class="directive"><a href="../mod/mod_proxy.html#proxypassmatch">ProxyPassMatch</a></code>.</p> + <p>Ceci est du au fait que ce drapeau induit l'utilisation du worker par défaut, qui + ne gère pas la mise en commun des connexions.</p> + <p>Partout où cela est possible, préférez l'utilisation de ces directives.</p> +</div> + <p>Note: <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code> doit être activé pour pouvoir utiliser ce drapeau.</p> @@ -569,10 +575,11 @@ Si par exemple, vous avez un <code class="directive"><a href="../mod/mod_alias.h vous devez utiliser le drapeau [PT] pour être sûr que l'<code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> sera bien évalué. </p> -<div class="example"><p><code> -Alias /icons /usr/local/apache/icons<br /> -RewriteRule /pics/(.+)\.jpg /icons/$1.gif [PT] -</code></p></div> +<pre class="prettyprint lang-config"> +Alias /icons /usr/local/apache/icons +RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT] +</pre> + <p> Dans l'exemple précédent, en l'absence du drapeau [PT], l'Alias aurait @@ -602,9 +609,9 @@ Avec le drapeau [QSA], les chaînes de requête peuvent être combinées. <p>Considérons la règle suivante :</p> -<div class="example"><p><code> -RewriteRule /pages/(.+) /page.php?page=$1 [QSA] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule /pages/(.+) /page.php?page=$1 +[QSA]</pre> + <p>Avec le drapeau [QSA], une requête pour <code>/pages/123?one=two</code> sera réécrite en @@ -652,10 +659,8 @@ navigateur. Si une URL pleinement qualifiée (FQDN - fully qualified domain name) <p><em>Tout</em> code de statut de réponse HTTP valide peut être spécifié, en utilisant la syntaxe [R=305], le code de statut 302 étant utilisé par défaut si aucun code n'est spécifié. Le code de statut -spécifié n'est pas nécessairement un code de statut de redirection (3xx). -</p> - -<p>Si le code de statut est en dehors de la plage des codes de +spécifié n'est pas nécessairement un code de statut +de redirection (3xx). Cependant, si le code de statut est en dehors de la plage des codes de redirection (300-399), la chaîne de substitution est entièrement supprimée, et la réécriture s'arrête comme si le drapeau <code>L</code> était utilisé.</p> @@ -677,52 +682,52 @@ avertissements 'Invalid URI in request'. <div class="section"> <h2><a name="flag_s" id="flag_s">S|skip</a></h2> <p>Le drapeau [S] sert à sauter des règles que vous ne voulez pas voir -exécuter. Ceci peut s'interpréter comme une instruction +exécuter. La syntaxe du drapeau [S] est [S=<em>N</em>], où +<em>N</em> correspond au nombre de règles à sauter. +Ceci peut s'interpréter comme une instruction <code>goto</code> dans votre jeu de règles de réécriture. Dans l'exemple suivant, nous ne voulons exécuter la règle <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> que si l'URI demandé ne correspond pas à un fichier existant.</p> - -<div class="example"><p><code> -# La requête concerne-t-elle un fichier qui n'existe pas ?<br /> -RewriteCond %{REQUEST_FILENAME} !-f<br /> -RewriteCond %{REQUEST_FILENAME} !-d<br /> -# Si c'est la cas, on saute les deux règles de réécriture suivantes<br /> -RewriteRule .? - [S=2]<br /> -<br /> -RewriteRule (.*\.gif) images.php?$1<br /> +<pre class="prettyprint lang-config"> +# La requête concerne-t-elle un fichier qui n'existe pas ? +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +# Si c'est la cas, on saute les deux règles de réécriture suivantes +RewriteRule .? - [S=2] + +RewriteRule (.*\.gif) images.php?$1 RewriteRule (.*\.html) docs.php?$1 -</code></p></div> +</pre> + + + <p>Cette technique trouve son utilité dans le fait qu'une directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> ne s'applique qu'à la règle qui la suit immédiatement. Ainsi, si vous voulez qu'une directive <code>RewriteCond</code> s'applique à plusieurs règles <code>RewriteRule</code>, une technique possible consiste à inverser ces -conditions et à ajouter une <code>RewriteRule</code> avec le drapeau [Skip]. Cette technique permet +conditions et ajouter une <code>RewriteRule</code> avec le drapeau [Skip]. Cette technique permet d'élaborer des pseudo-constructions if-then-else : la dernière règle du bloc then contiendra <code>skip=N</code>, où N est le nombre de règles contenues dans le bloc else :</p> -<div class="example"><p><code> -# Est-ce que le fichier existe ?<br /> -RewriteCond %{REQUEST_FILENAME} !-f<br /> -RewriteCond %{REQUEST_FILENAME} !-d<br /> +<pre class="prettyprint lang-config"> +# Est-ce que le fichier existe ? +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza. +RewriteRule .? - [S=3] -# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.<br /> -RewriteRule .? - [S=3]<br /> -<br /> # Si le fichier existe, alors : -<span class="indent"> - RewriteRule (.*\.gif) images.php?$1<br /> - RewriteRule (.*\.html) docs.php?$1<br /> - # Skip past the "else" stanza.<br /> - RewriteRule .? - [S=1]<br /> -</span> +RewriteRule (.*\.gif) images.php?$1 + RewriteRule (.*\.html) docs.php?$1 + # Skip past the "else" stanza. + RewriteRule .? - [S=1] # ELSE... -<span class="indent"> - RewriteRule (.*) 404.php?file=$1<br /> -</span> +RewriteRule (.*) 404.php?file=$1 # END -</code></p></div> +</pre> + <p>Il est probablement plus aisé de définir ce genre de configuration via les directives <code class="directive"><If></code>, <code class="directive"><ElseIf></code>, et <code class="directive"><Else></code>.</p> @@ -737,19 +742,21 @@ identique à celui de la directive <code class="directive"><a href="../mod/mod_mi du code source Perl en tant que plein texte, s'il est requis d'une certaine manière :</p> -<div class="example"><p><code> -# Sert les fichier .pl en tant que plein texte<br /> +<pre class="prettyprint lang-config"> +# Sert les fichier .pl en tant que plein texte RewriteRule \.pl$ - [T=text/plain] -</code></p></div> +</pre> + <p>Ou encore, si vous possédez une caméra qui produit des fichiers images jpeg sans extension, vous pouvez forcer le renvoi de ces images avec le type MIME correct en se basant sur le nom du fichier :</p> -<div class="example"><p><code> -# Les fichiers dont le nom contient 'IMG' sont des images jpg.<br /> +<pre class="prettyprint lang-config"> +# Les fichiers dont le nom contient 'IMG' sont des images jpg. RewriteRule IMG - [T=image/jpg] -</code></p></div> +</pre> + <p>Notez cependant qu'il s'agit d'un exemple trivial, et que le problème aurait pu être résolu en utilisant à la place la directive <code class="directive"><a href="../mod/core.html#filesmatch"><FilesMatch></a></code>. Il faut toujours @@ -770,7 +777,28 @@ utiliser le drapeau <code>L</code> pour terminer la séquence <div class="bottomlang"> <p><span>Langues Disponibles: </span><a href="../en/rewrite/flags.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/flags.html" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/flags.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/htaccess.html.en b/docs/manual/rewrite/htaccess.html.en index a28c1cc5..5e24cdbb 100644 --- a/docs/manual/rewrite/htaccess.html.en +++ b/docs/manual/rewrite/htaccess.html.en @@ -8,10 +8,13 @@ <title>mod_rewrite and .htaccess files - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -29,12 +32,33 @@ the way that the rules change when you use mod_rewrite in .htaccess files, and how to deal with these changes.</p> </div> -<div id="quickview"><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="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +<div id="quickview"><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="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> </div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/htaccess.html" title="English"> en </a> | <a href="../fr/rewrite/htaccess.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/htaccess.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/htaccess.html.fr b/docs/manual/rewrite/htaccess.html.fr index d4280620..99bb3a21 100644 --- a/docs/manual/rewrite/htaccess.html.fr +++ b/docs/manual/rewrite/htaccess.html.fr @@ -8,10 +8,13 @@ <title>mod_rewrite et les fichiers .htaccess - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -30,12 +33,33 @@ travailler avec ces changements.</p> </div> <div id="quickview"><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="vhosts.html">Serveurs virtuels</a></li><li><a href="proxy.html">Serveurs mandataires</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></ul></div> +correspondance</a></li><li><a href="vhosts.html">Serveurs virtuels</a></li><li><a href="proxy.html">Serveurs mandataires</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></ul><ul class="seealso"><li><a href="#comments_section">Commentaires</a></li></ul></div> </div> <div class="bottomlang"> <p><span>Langues Disponibles: </span><a href="../en/rewrite/htaccess.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/htaccess.html" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/htaccess.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/index.html.en b/docs/manual/rewrite/index.html.en index f826dcce..edbc41c0 100644 --- a/docs/manual/rewrite/index.html.en +++ b/docs/manual/rewrite/index.html.en @@ -8,10 +8,13 @@ <title>Apache mod_rewrite - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="../"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -51,7 +54,7 @@ <p>Since mod_rewrite is so powerful, it can indeed be rather complex. This document supplements the <a href="../mod/mod_rewrite.html">reference documentation</a>, and attempts to allay some of that complexity, and provide highly - annoted examples of common scenarios that you may handle with + annotated examples of common scenarios that you may handle with mod_rewrite. But we also attempt to show you when you should not use mod_rewrite, and use other standard Apache features instead, thus avoiding this unnecessary complexity.</p> @@ -83,5 +86,9 @@ wiki</a></li><li><a href="../glossary.html">Glossary</a></li></ul></div> <a href="../zh-cn/rewrite/" hreflang="zh-cn" rel="alternate" title="Simplified Chinese"> zh-cn </a></p> </div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/index.html.fr b/docs/manual/rewrite/index.html.fr index 080de419..b1bc1388 100644 --- a/docs/manual/rewrite/index.html.fr +++ b/docs/manual/rewrite/index.html.fr @@ -8,10 +8,13 @@ <title>Le module Apache mod_rewrite - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="../"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -97,5 +100,9 @@ avec le système de fichiers</a></li><li><a href="http://wiki.apache.org/httpd/Re <a href="../zh-cn/rewrite/" hreflang="zh-cn" rel="alternate" title="Simplified Chinese"> zh-cn </a></p> </div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/index.html.tr.utf8 b/docs/manual/rewrite/index.html.tr.utf8 index 4aaf18c1..098a87bf 100644 --- a/docs/manual/rewrite/index.html.tr.utf8 +++ b/docs/manual/rewrite/index.html.tr.utf8 @@ -8,10 +8,13 @@ <title>Apache mod_rewrite - Apache HTTP Sunucusu</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modüller</a> | <a href="../mod/directives.html">Yönergeler</a> | <a href="../faq/">SSS</a> | <a href="../glossary.html">Terimler</a> | <a href="../sitemap.html">Site Haritası</a></p> +<p class="menu"><a href="../mod/">Modüller</a> | <a href="../mod/directives.html">Yönergeler</a> | <a href="http://wiki.apache.org/httpd/FAQ">SSS</a> | <a href="../glossary.html">Terimler</a> | <a href="../sitemap.html">Site Haritası</a></p> <p class="apache">Apache HTTP Sunucusu Sürüm 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="../"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -23,6 +26,7 @@ <a href="../tr/rewrite/" title="Türkçe"> tr </a> | <a href="../zh-cn/rewrite/" hreflang="zh-cn" rel="alternate" title="Simplified Chinese"> zh-cn </a></p> </div> +<div class="outofdate">Bu çeviri güncel olmayabilir. Son değişiklikler için İngilizce sürüm geçerlidir.</div> <p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> modülü gelen URL isteklerinde değişiklik yapabilmek için <a href="intro.html#regex">düzenli ifade</a> kurallarına @@ -78,5 +82,9 @@ <a href="../zh-cn/rewrite/" hreflang="zh-cn" rel="alternate" title="Simplified Chinese"> zh-cn </a></p> </div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br /><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> altında lisanslıdır.</p> -<p class="menu"><a href="../mod/">Modüller</a> | <a href="../mod/directives.html">Yönergeler</a> | <a href="../faq/">SSS</a> | <a href="../glossary.html">Terimler</a> | <a href="../sitemap.html">Site Haritası</a></p></div> +<p class="menu"><a href="../mod/">Modüller</a> | <a href="../mod/directives.html">Yönergeler</a> | <a href="http://wiki.apache.org/httpd/FAQ">SSS</a> | <a href="../glossary.html">Terimler</a> | <a href="../sitemap.html">Site Haritası</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/index.html.zh-cn b/docs/manual/rewrite/index.html.zh-cn index d5c650e3..4d603e8b 100644 --- a/docs/manual/rewrite/index.html.zh-cn +++ b/docs/manual/rewrite/index.html.zh-cn @@ -8,10 +8,13 @@ <title>Apache mod_rewrite - Apache HTTP æœåС噍</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">模å—</a> | <a href="../mod/directives.html">指令</a> | <a href="../faq/">常è§é—®é¢˜</a> | <a href="../glossary.html">术è¯</a> | <a href="../sitemap.html">网站导航</a></p> +<p class="menu"><a href="../mod/">模å—</a> | <a href="../mod/directives.html">指令</a> | <a href="http://wiki.apache.org/httpd/FAQ">常è§é—®é¢˜</a> | <a href="../glossary.html">术è¯</a> | <a href="../sitemap.html">网站导航</a></p> <p class="apache">Apache HTTP æœåŠ¡å™¨ç‰ˆæœ¬ 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="../"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -67,5 +70,9 @@ wiki</a></li><li><a href="../glossary.html">术è¯</a></li></ul></div> <a href="../zh-cn/rewrite/" title="Simplified Chinese"> zh-cn </a></p> </div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />基于 <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> 许å¯è¯.</p> -<p class="menu"><a href="../mod/">模å—</a> | <a href="../mod/directives.html">指令</a> | <a href="../faq/">常è§é—®é¢˜</a> | <a href="../glossary.html">术è¯</a> | <a href="../sitemap.html">网站导航</a></p></div> +<p class="menu"><a href="../mod/">模å—</a> | <a href="../mod/directives.html">指令</a> | <a href="http://wiki.apache.org/httpd/FAQ">常è§é—®é¢˜</a> | <a href="../glossary.html">术è¯</a> | <a href="../sitemap.html">网站导航</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/intro.html.en b/docs/manual/rewrite/intro.html.en index de7827b7..102203bc 100644 --- a/docs/manual/rewrite/intro.html.en +++ b/docs/manual/rewrite/intro.html.en @@ -8,10 +8,13 @@ <title>Apache mod_rewrite Introduction - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -36,7 +39,7 @@ but this doc should help the beginner get their feet wet. <li><img alt="" src="../images/down.gif" /> <a href="#rewritecond">Rewrite Conditions</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#rewritemap">Rewrite maps</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#htaccess">.htaccess files</a></li> -</ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="introduction" id="introduction">Introduction</a></h2> @@ -138,14 +141,19 @@ 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 strings <em>Substitution</em> and <em>TestString</em>. - Figure 1 shows to which locations the back-references are - transferred for expansion as well as illustrating the flow of the - RewriteRule, RewriteCond matching.</p> + the strings <em>Substitution</em> and <em>TestString</em> as + outlined in the following chapters. 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> <p class="figure"> - <img src="../images/rewrite_rule_flow.png" alt="Flow of RewriteRule and RewriteCond matching" /><br /> - <dfn>Figure 1:</dfn> The back-reference flow through a rule. + <img src="../images/rewrite_backreferences.png" alt="Flow of RewriteRule and RewriteCond matching" /><br /> + <dfn>Figure 1:</dfn> The back-reference flow through a rule.<br /> + In this example, a request for <code>/test/1234</code> would be transformed into <code>/admin.foo?page=test&id=1234&host=admin.example.com</code>. </p> @@ -160,10 +168,15 @@ 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 always a <a href="#regex">regular -expression</a> 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).</p> +<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> <p class="figure"> <img src="../images/syntax_rewriterule.png" alt="Syntax of the RewriteRule directive" /><br /> @@ -176,18 +189,20 @@ the beginning of a query string).</p> <dl> <dt>A full filesystem path to a resource</dt> <dd> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/games /usr/local/games/web -</code></p></div> +</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> <dd> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/foo$ /bar -</code></p></div> +</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 @@ -196,9 +211,10 @@ path <code>/usr/local/apache2/htdocs/bar</code>.</p> <dt>An absolute URL</dt> <dd> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R] -</code></p></div> +</pre> + <p>This tells the client to make a new request for the specified URL.</p> </dd> </dl> @@ -206,9 +222,10 @@ RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R] <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> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1 -</code></p></div> +</pre> + <p>The variable <code>$1</code> will be replaced with whatever text was matched by the expression inside the parenthesis in the <var>Pattern</var>. For example, a request @@ -229,9 +246,10 @@ application of one or more flags to the end of the rule. For example, the matching behavior of a rule can be made case-insensitive by the application of the <code>[NC]</code> flag: </p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^puppy.html smalldog.html [NC] -</code></p></div> +</pre> + <p>For more details on the available flags, their meanings, and examples, see the <a href="flags.html">Rewrite Flags</a> document.</p> @@ -255,10 +273,11 @@ 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> -<div class="example"><p><code> -RewriteCond %{REMOTE_ADDR} ^10\.2\.<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{REMOTE_ADDR} ^10\.2\. RewriteRule (.*) http://intranet.example.com$1 -</code></p></div> +</pre> + <p>When more than one <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> is @@ -267,11 +286,12 @@ the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">Rewrit 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> -<div class="example"><p><code> -RewriteCond %{QUERY_STRING} hack<br /> -RewriteCond %{HTTP_COOKIE} !go<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{QUERY_STRING} hack +RewriteCond %{HTTP_COOKIE} !go RewriteRule . - [F] -</code></p></div> +</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> <p>Matches in the regular expressions contained in @@ -281,10 +301,11 @@ the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">Rewrit 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> -<div class="example"><p><code> -RewriteCond %{HTTP_HOST} (.*)<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_HOST} (.*) RewriteRule ^/(.*) /sites/%1/$1 -</code></p></div> +</pre> + <p>If the request was for <code>http://example.com/foo/bar</code>, then <code>%1</code> would contain <code>example.com</code> and <code>$1</code> would contain <code>foo/bar</code>.</p> @@ -321,7 +342,28 @@ the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">Rewrit <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/intro.html" title="English"> en </a> | <a href="../fr/rewrite/intro.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/intro.html.fr b/docs/manual/rewrite/intro.html.fr index 20c93866..50bbc8ef 100644 --- a/docs/manual/rewrite/intro.html.fr +++ b/docs/manual/rewrite/intro.html.fr @@ -8,10 +8,13 @@ <title>Introduction au module Apache mod_rewrite - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -21,6 +24,8 @@ <p><span>Langues Disponibles: </span><a href="../en/rewrite/intro.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/intro.html" title="Français"> fr </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>Ce document est un complément à la <a href="../mod/mod_rewrite.html">documentation de référence</a> du module <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. Il décrit les concepts de base dont la @@ -39,7 +44,7 @@ pieds. <li><img alt="" src="../images/down.gif" /> <a href="#htaccess">Fichiers .htaccess</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="remapping.html">Redirection and 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></ul></div> +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></ul><ul class="seealso"><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="introduction" id="introduction">Introduction</a></h2> @@ -155,16 +160,22 @@ arrières dans les expressions rationnelles</a></h3> 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 des chaînes de - <em>Substitution</em> et des <em>Chaînes de test</em>. La - figure 1 + <em>Substitution</em> et des <em>Chaînes de test</em> comme + précisé dans les chapitres suivants. La figure 1 montre à quels endroits les références arrières sont suceptibles d'être développées, et illustre le flux des comparaisons - effectuées par les règles RewriteRule et RewriteCond.</p> + effectuées par les règles RewriteRule et + RewriteCond. Dans les chapitres suivants, nous examinerons comment + utiliser ces références arrières, donc ne vous affolez pas si + elles vous paraissent un peu exotiques au premier abord.</p> <p class="figure"> - <img src="../images/rewrite_rule_flow.png" alt="Flux des comparaisons effectuées par les règles RewriteRule et RewriteCond" /><br /> + <img src="../images/rewrite_backreferences.png" alt="Flux des comparaisons effectuées par les règles RewriteRule et RewriteCond" /><br /> <dfn>Figure 1 :</dfn> Le cheminement d'une référence arrière à - travers une règle. + travers une règle.<br /> + Dans cet exemple, une requête pour <code>/test/1234</code> serait + transformée en + <code>/admin.foo?page=test&id=1234&host=admin.example.com</code>. </p> @@ -181,10 +192,17 @@ transformée;</li> <li><var>[drapeaux]</var>: options affectant la requête réécrite.</li> </ol> -<p>Le <var>Modèle</var> est toujours une <a href="#regex">expression -rationnelle</a> comparée au chemin de l'URL de la requête entrante (la +<p>Le <var>Modèle</var> est une <a href="#regex">expression +rationnelle</a>. Au sein de la première règle de réécriture, ou jusqu'à +ce qu'une substitution survienne, elle est comparée au chemin de +l'URL de la requête entrante (la partie située après le nom d'hôte mais avant tout point d'interrogation -qui indique le début d'une chaîne de requête).</p> +qui indique le début d'une chaîne de paramètres de +requête) ou, dans un contexte de répertoire, au chemin de la +requête relativement au répertoire pour lequel la +règle est définie. Lorsqu'une substitution a eu lieu, les +règles suivantes effectuent leurs comparaisons par rapport à la valeur +substituée.</p> <p class="figure"> <img src="../images/syntax_rewriterule.png" alt="Syntaxe de la directive RewriteRule" /><br /> @@ -197,18 +215,20 @@ trois types :</p> <dl> <dt>Un chemin complet du système de fichiers vers une ressource</dt> <dd> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/jeux /usr/local/jeux/web -</code></p></div> +</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> <dd> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/foo$ /bar -</code></p></div> +</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 @@ -217,9 +237,10 @@ chemin <code>/usr/local/apache2/htdocs/bar</code>.</p> <dt>Une URL absolue</dt> <dd> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/produits/vues$ http://site2.example.com/voirproduits.html [R] -</code></p></div> +</pre> + <p>Ceci informe le client qu'il doit effectuer une nouvelle requête vers l'URL spécifiée.</p> </dd> @@ -228,9 +249,10 @@ l'URL spécifiée.</p> <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> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^/produits/(.*)/view$ /var/web/produitsdb/$1 -</code></p></div> +</pre> + <p>La variable <code>$1</code> sera remplacée par tout texte correspondant à l'expression située entre les parenthèses dans le <var>Modèle</var>. Par exemple, une requête pour @@ -250,9 +272,10 @@ présence d'un ou plusieurs drapeaux en fin de règle. Par exemple, les conditions de correspondance d'une règle peuvent être rendues insensibles à la casse par la présence du drapeau <code>[NC]</code> : </p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteRule ^puppy.html petitchien.html [NC] -</code></p></div> +</pre> + <p>Pour une liste des drapeaux disponibles, leurs significations, et des exemples, voir le document <a href="flags.html">Drapeaux de @@ -278,21 +301,23 @@ correspondance est évaluée.</p> <p>Par exemple, pour renvoyer toutes les requêtes en provenance d'une certaine tranche d'adresses IP vers un autre serveur, vous pouvez utiliser :</p> -<div class="example"><p><code> -RewriteCond %{REMOTE_ADDR} ^10\.2\.<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{REMOTE_ADDR} ^10\.2\. RewriteRule (.*) http://intranet.example.com$1 -</code></p></div> +</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 doivent toutes être satisfaites pour que la règle <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> suivante s'applique. Par exemple, 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> -<div class="example"><p><code> -RewriteCond %{QUERY_STRING} hack<br /> -RewriteCond %{HTTP_COOKIE} !go<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{QUERY_STRING} hack +RewriteCond %{HTTP_COOKIE} !go RewriteRule . - [F] -</code></p></div> +</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> @@ -303,10 +328,11 @@ de la règle <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule 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> -<div class="example"><p><code> -RewriteCond %{HTTP_HOST} (.*)<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_HOST} (.*) RewriteRule ^/(.*) /sites/%1/$1 -</code></p></div> +</pre> + <p>Si la requête concernait <code>http://example.com/foo/bar</code>, alors <code>%1</code> contiendrait <code>example.com</code> et <code>$1</code> contiendrait <code>foo/bar</code>.</p> @@ -345,7 +371,28 @@ 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"> en </a> | <a href="../fr/rewrite/intro.html" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/proxy.html.en b/docs/manual/rewrite/proxy.html.en index 3f56ffae..a8c2a899 100644 --- a/docs/manual/rewrite/proxy.html.en +++ b/docs/manual/rewrite/proxy.html.en @@ -8,10 +8,13 @@ <title>Using mod_rewrite for Proxying - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -28,7 +31,7 @@ how to use the RewriteRule's [P] flag to proxy content to another server. A number of recipes are provided that describe common scenarios.</p> </div> -<div id="quickview"><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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +<div id="quickview"><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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="dynamic-proxy" id="dynamic-proxy">Proxying Content with mod_rewrite</a></h2> @@ -53,24 +56,26 @@ A number of recipes are provided that describe common scenarios.</p> <p>To simply map a URL to another server, we use the [P] flag, as follows:</p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteBase /products/<br /> -RewriteRule ^<strong>widget/</strong>(.*)$ <strong>http://product.example.com/widget/</strong>$1 [<strong>P</strong>]<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteBase /products/ +RewriteRule ^widget/(.*)$ http://product.example.com/widget/$1 [P] ProxyPassReverse /products/widget/ http://product.example.com/widget/ -</code></p></div> +</pre> + <p>In the second example, we proxy the request only if we can't find the resource locally. This can be very useful when you're migrating from one server to another, and you're not sure if all the content has been migrated yet.</p> -<div class="example"><p><code> -RewriteCond %{REQUEST_FILENAME} <strong>!-f</strong><br /> -RewriteCond %{REQUEST_FILENAME} <strong>!-d</strong><br /> -RewriteRule ^/(.*) http://<strong>old</strong>.example.com/$1 [<strong>P</strong>]<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^/(.*) http://old.example.com/$1 [P] ProxyPassReverse / http://old.example.com/ -</code></p></div> +</pre> + </dd> <dt>Discussion:</dt> @@ -87,7 +92,28 @@ ProxyPassReverse / http://old.example.com/ </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/proxy.html" title="English"> en </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/proxy.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/remapping.html.en b/docs/manual/rewrite/remapping.html.en index 98067870..0b97d283 100644 --- a/docs/manual/rewrite/remapping.html.en +++ b/docs/manual/rewrite/remapping.html.en @@ -8,10 +8,13 @@ <title>Redirecting and Remapping with mod_rewrite - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -46,7 +49,7 @@ configuration.</div> <li><img alt="" src="../images/down.gif" /> <a href="#canonicalurl">Canonical URLs</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#moveddocroot">Moved <code>DocumentRoot</code></a></li> <li><img alt="" src="../images/down.gif" /> <a href="#fallback-resource">Fallback Resource</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="old-to-new" id="old-to-new">From Old to New (internal)</a></h2> @@ -71,10 +74,11 @@ configuration.</div> <p>We rewrite the old URL to the new one internally via the following rule:</p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteRule ^<strong>/old</strong>\.html$ <strong>/new</strong>.html [PT] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT] +</pre> + </dd> </dl> @@ -102,10 +106,11 @@ RewriteRule ^<strong>/old</strong>\.html$ <strong>/new</strong>.html [PT] <p>We force a HTTP redirect to the new URL which leads to a change of the browsers and thus the users view:</p> -<div class="example"><p><code> -RewriteEngine on<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<strong>R</strong>] -</code></p></div> +</pre> + </dd> <dt>Discussion</dt> @@ -115,9 +120,8 @@ RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<stron use the Redirect directive. mod_rewrite was used in that earlier example in order to hide the redirect from the client:</p> - <div class="example"><p><code> - Redirect /foo.html /bar.html - </code></p></div> + <pre class="prettyprint lang-config">Redirect /foo.html /bar.html</pre> + </dd> </dl> @@ -144,18 +148,21 @@ RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<stron to the new server, but you might also consider using the Redirect or RedirectMatch directive.</p> -<div class="example"><h3>With mod_rewrite</h3><p><code> -RewriteEngine on<br /> +<pre class="prettyprint lang-config">#With mod_rewrite +RewriteEngine on RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L] -</code></p></div> +</pre> -<div class="example"><h3>With RedirectMatch</h3><p><code> + +<pre class="prettyprint lang-config">#With RedirectMatch RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1 -</code></p></div> +</pre> -<div class="example"><h3>With Redirect</h3><p><code> + +<pre class="prettyprint lang-config">#With Redirect Redirect /docs/ http://new.example.com/docs/ -</code></p></div> +</pre> + </dd> </dl> @@ -185,11 +192,12 @@ Redirect /docs/ http://new.example.com/docs/ internally leads to the invocation of <code>/~quux/foo.cgi</code>.</p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteBase /~quux/<br /> -RewriteRule ^foo\.<strong>html</strong>$ foo.<strong>cgi</strong> [H=<strong>cgi-script</strong>] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteBase /~quux/ +RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] +</pre> + </dd> </dl> @@ -216,21 +224,20 @@ RewriteRule ^foo\.<strong>html</strong>$ foo.<strong>cgi</strong> [H=<stron existence of the new extension. If it exists, we take that name, else we rewrite the URL to its original state.</p> -<div class="example"><p><code> -# backward compatibility ruleset for<br /> -# rewriting document.html to document.php<br /> -# when and only when document.php exists<br /> -<Directory /var/www/htdocs><br /> -<span class="indent"> -RewriteEngine on<br /> -RewriteBase /var/www/htdocs<br /> -<br /> -RewriteCond $1.php -f<br /> -RewriteCond $1.html !-f<br /> -RewriteRule ^(.*).html$ $1.php<br /> -</span> +<pre class="prettyprint lang-config"> +# backward compatibility ruleset for +# rewriting document.html to document.php +# when and only when document.php exists +<Directory /var/www/htdocs> + RewriteEngine on + RewriteBase /var/www/htdocs + + RewriteCond $1.php -f + RewriteCond $1.html !-f + RewriteRule ^(.*).html$ $1.php </Directory> -</code></p></div> +</pre> + </dd> <dt>Discussion</dt> @@ -277,64 +284,61 @@ but rather uses the <code class="directive"><a href="../mod/mod_alias.html#redir directive placed in a virtual host for the non-canonical hostname(s).</p> -<div class="example"><p><code> -<VirtualHost *:80><br /> -<span class="indent"> - ServerName undesired.example.com<br /> - ServerAlias example.com notthis.example.com<br /> -<br /> - Redirect / http://www.example.com/<br /> -</span> -</VirtualHost><br /> -<br /> -<VirtualHost *:80><br /> -<span class="indent"> - ServerName www.example.com<br /> -</span> +<pre class="prettyprint lang-config"> +<VirtualHost *:80> + ServerName undesired.example.com + ServerAlias example.com notthis.example.com + + Redirect / http://www.example.com/ </VirtualHost> -</code></p></div> + +<VirtualHost *:80> + ServerName www.example.com +</VirtualHost> +</pre> + <p>You can alternatively accomplish this using the <code class="directive"><a href="../mod/core.html#if"><If></a></code> directive:</p> -<div class="example"><p><code> -<If "%{HTTP_HOST} != 'www.example.com'"><br /> -<span class="indent"> -Redirect / http://www.example.com/ -</span> +<pre class="prettyprint lang-config"> +<If "%{HTTP_HOST} != 'www.example.com'"> + Redirect / http://www.example.com/ </If> -</code></p></div> +</pre> + <p>Or, for example, to redirect a portion of your site to HTTPS, you might do the following:</p> -<div class="example"><p><code> -<If "%{SERVER_PROTOCOL} != 'HTTPS'"><br /> -<span class="indent"> -Redirect /admin/ https://www.example.com/admin/ -</span> +<pre class="prettyprint lang-config"> +<If "%{SERVER_PROTOCOL} != 'HTTPS'"> + Redirect /admin/ https://www.example.com/admin/ </If> -</code></p></div> +</pre> + <p>If, for whatever reason, you still want to use <code>mod_rewrite</code> - if, for example, you need this to work with a larger set of RewriteRules - you might use one of the recipes below.</p> <p>For sites running on a port other than 80:</p> -<div class="example"><p><code> -RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]<br /> -RewriteCond %{HTTP_HOST} !^$<br /> -RewriteCond %{SERVER_PORT} !^80$<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] +RewriteCond %{HTTP_HOST} !^$ +RewriteCond %{SERVER_PORT} !^80$ RewriteRule ^/?(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R,NE] -</code></p></div> +</pre> + <p>And for a site running on port 80</p> -<div class="example"><p><code> -RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]<br /> -RewriteCond %{HTTP_HOST} !^$<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] +RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE] -</code></p></div> +</pre> + <p> If you wanted to do this generically for all domain names - that @@ -343,11 +347,12 @@ RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE] <strong>example.com</strong>, you could use the following recipe:</p> -<div class="example"><p><code> -RewriteCond %{HTTP_HOST} !^www\. [NC]<br /> -RewriteCond %{HTTP_HOST} !^$<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_HOST} !^www\. [NC] +RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] -</code></p></div> +</pre> + <p>These rulesets will work either in your main server configuration file, or in a <code>.htaccess</code> file placed in the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> of the server.</p> @@ -377,23 +382,24 @@ RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] resource, and, if not finding it in either place, will attempt to just serve it out of the location requested.</p> -<div class="example"><p><code> -RewriteEngine on<br /> -<br /> -# first try to find it in dir1/...<br /> -# ...and if found stop and be happy:<br /> -RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI} -f<br /> -RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1 [L]<br /> -<br /> -# second try to find it in dir2/...<br /> -# ...and if found stop and be happy:<br /> -RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI} -f<br /> -RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L]<br /> -<br /> -# else go on for other Alias or ScriptAlias directives,<br /> -# etc.<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on + +# first try to find it in dir1/... +# ...and if found stop and be happy: +RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI} -f +RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1 [L] + +# second try to find it in dir2/... +# ...and if found stop and be happy: +RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI} -f +RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L] + +# else go on for other Alias or ScriptAlias directives, +# etc. RewriteRule ^ - [PT] -</code></p></div> +</pre> + </dd> </dl> @@ -421,13 +427,14 @@ RewriteRule ^ - [PT] <p>We'll use a <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive to build a list of servers that we wish to use.</p> -<div class="example"><p><code> -HostnameLookups on<br /> -RewriteEngine on<br /> -RewriteMap multiplex txt:/path/to/map.mirrors<br /> -RewriteCond %{REMOTE_HOST} ([a-z]+)$ [NC]<br /> +<pre class="prettyprint lang-config"> +HostnameLookups on +RewriteEngine on +RewriteMap multiplex txt:/path/to/map.mirrors +RewriteCond %{REMOTE_HOST} ([a-z]+)$ [NC] RewriteRule ^/(.*)$ ${multiplex:<strong>%1</strong>|http://www.example.com/}$1 [R,L] -</code></p></div> +</pre> + <div class="example"><p><code> ## map.mirrors -- Multiplexing Map<br /> @@ -481,16 +488,17 @@ com http://www.example.com/<br /> All other browsers receive page <code>foo.32.html</code>. This is done with the following ruleset:</p> -<div class="example"><p><code> -RewriteCond %{HTTP_USER_AGENT} ^<strong>Mozilla/3</strong>.*<br /> -RewriteRule ^foo\.html$ foo.<strong>NS</strong>.html [<strong>L</strong>]<br /> -<br /> -RewriteCond %{HTTP_USER_AGENT} ^<strong>Lynx/</strong> [OR]<br /> -RewriteCond %{HTTP_USER_AGENT} ^<strong>Mozilla/[12]</strong><br /> -RewriteRule ^foo\.html$ foo.<strong>20</strong>.html [<strong>L</strong>]<br /> -<br /> +<pre class="prettyprint lang-config"> +RewriteCond %{HTTP_USER_AGENT} ^<strong>Mozilla/3</strong>.* +RewriteRule ^foo\.html$ foo.<strong>NS</strong>.html [<strong>L</strong>] + +RewriteCond %{HTTP_USER_AGENT} ^Lynx/ [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[12] +RewriteRule ^foo\.html$ foo.<strong>20</strong>.html [<strong>L</strong>] + RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L</strong>] -</code></p></div> +</pre> + </dd> </dl> @@ -521,9 +529,8 @@ RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L we replace <code>/puppies</code> and <code>/canines</code> by the canonical <code>/dogs</code>.</p> -<div class="example"><p><code> -RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R]</pre> + </dd> <dt>Discussion:</dt> @@ -531,9 +538,8 @@ RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R] This should really be accomplished with Redirect or RedirectMatch directives: - <div class="example"><p><code> - RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2 - </code></p></div> + <pre class="prettyprint lang-config"> RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2 </pre> + </dd> </dl> @@ -562,16 +568,16 @@ using the following ruleset:</p> <code>/about/</code>: </p> -<div class="example"><p><code> -RewriteEngine on<br /> -RewriteRule <strong>^/$</strong> /about/ [<strong>R</strong>] -</code></p></div> +<pre class="prettyprint lang-config"> +RewriteEngine on +RewriteRule ^/$ /about/ [<strong>R</strong>] +</pre> + <p>Note that this can also be handled using the <code class="directive"><a href="../mod/mod_alias.html#redirectmatch">RedirectMatch</a></code> directive:</p> -<div class="example"><p><code> -RedirectMatch ^/$ http://example.com/about/ -</code></p></div> +<pre class="prettyprint lang-config">RedirectMatch ^/$ http://example.com/about/</pre> + <p>Note also that the example rewrites only the root URL. That is, it rewrites a request for <code>http://example.com/</code>, but not a @@ -599,36 +605,33 @@ that should go to an existing resource such as an image, or a css file.</dd> <dd> <p>As of version 2.2.16, you should use the <code class="directive"><a href="../mod/mod_dir.html#fallbackresource">FallbackResource</a></code> directive for this:</p> -<div class="example"><p><code> -<Directory /var/www/my_blog><br /> -<span class="indent"> - FallbackResource index.php<br /> -</span> +<pre class="prettyprint lang-config"> +<Directory /var/www/my_blog> + FallbackResource index.php </Directory> -</code></p></div> +</pre> + <p>However, in earlier versions of Apache, or if your needs are more complicated than this, you can use a variation of the following rewrite set to accomplish the same thing:</p> -<div class="example"><p><code> -<Directory /var/www/my_blog><br /> -<span class="indent"> - RewriteBase /my_blog<br /> -<br /> - RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f<br /> - RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d<br /> - RewriteRule ^ index.php [PT]<br /> -</span> +<pre class="prettyprint lang-config"> +<Directory /var/www/my_blog> + RewriteBase /my_blog + + RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f + RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d + RewriteRule ^ index.php [PT] </Directory> -</code></p></div> +</pre> + <p>If, on the other hand, you wish to pass the requested URI as a query string argument to index.php, you can replace that RewriteRule with:</p> -<div class="example"><p><code> - RewriteRule (.*) index.php?$1 [PT,QSA] -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule (.*) index.php?$1 [PT,QSA]</pre> + <p>Note that these rulesets can be used in a <code>.htaccess</code> file, as well as in a <Directory> block.</p> @@ -640,7 +643,28 @@ file, as well as in a <Directory> block.</p> </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/remapping.html" title="English"> en </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/remapping.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/rewritemap.html.en b/docs/manual/rewrite/rewritemap.html.en index 42ab8c68..44f3d062 100644 --- a/docs/manual/rewrite/rewritemap.html.en +++ b/docs/manual/rewrite/rewritemap.html.en @@ -8,10 +8,13 @@ <title>Using RewriteMap - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -41,7 +44,7 @@ configuration.</div> <li><img alt="" src="../images/down.gif" /> <a href="#prg">prg: External Rewriting Program</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#dbd">dbd or fastdbd: SQL Query</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#summary">Summary</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="introduction" id="introduction">Introduction</a></h2> @@ -61,9 +64,8 @@ configuration.</div> <p>The syntax of the <code>RewriteMap</code> directive is as follows:</p> -<div class="example"><p><code> -RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em> -</code></p></div> +<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em></pre> + <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is an arbitray name that you assign to the map, and which you will use in @@ -87,21 +89,18 @@ RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em> <p>For example, you might define a <code class="directive">RewriteMap</code> as:</p> - <div class="example"><p><code> - RewriteMap examplemap txt:/path/to/file/map.txt - </code></p></div> + <pre class="prettyprint lang-config">RewriteMap examplemap txt:/path/to/file/map.txt</pre> + <p>You would then be able to use this map in a <code class="directive">RewriteRule</code> as follows:</p> -<div class="example"><p><code> - RewriteRule ^/ex/(.*) ${examplemap:$1} -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1}</pre> + <p>A default value can be specified in the event that nothing is found in the map:</p> -<div class="example"><p><code> -RewriteRule ^/ex/(.*) ${examplemap:$1|/not_found.html} -</code></p></div> +<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1|/not_found.html}</pre> + <div class="note"><h3>Per-directory and .htaccess context</h3> <p> @@ -142,11 +141,12 @@ may be used, and give examples of each.</p> <p>For example, we might use a mapfile to translate product names to product IDs for easier-to-remember URLs, using the following recipe:</p> +<p><strong>Product to ID configuration</strong></p> + <pre class="prettyprint lang-config"> +RewriteMap product2id txt:/etc/apache2/productmap.txt +RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT] + </pre> - <div class="example"><h3>Product to ID configuration</h3><p><code> - RewriteMap product2id txt:/etc/apache2/productmap.txt<br /> - RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT] - </code></p></div> <p>We assume here that the <code>prods.php</code> script knows what to do when it received an argument of <code>id=NOTFOUND</code> when @@ -176,9 +176,8 @@ telephone 328 scope. If you're planning to use this in a <code>.htaccess</code> file, you'll need to remove the leading slash from the rewrite pattern in order for it to match anything: - <div class="example"><p><code> - RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT] - </code></p></div> + <pre class="prettyprint lang-config">RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre> + </div> <div class="note"><h3>Cached lookups</h3> @@ -215,13 +214,14 @@ telephone 328 static www1|www2|www3|www4<br /> dynamic www5|www6 </code></p></div> +<p><strong>Configuration directives</strong></p> + <pre class="prettyprint lang-config"> +RewriteMap servers rnd:/path/to/file/map.txt + +RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L] +RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L] + </pre> - <div class="example"><h3>Configuration directives</h3><p><code> - RewriteMap servers rnd:/path/to/file/map.txt<br /> - <br /> - RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L]<br /> - RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L] - </code></p></div> <p>So, when an image is requested and the first of these rules is matched, <code>RewriteMap</code> looks up the string @@ -252,9 +252,10 @@ static www1|www1|www2|www3|www4 <p>You may optionally specify a particular dbm type:</p> - <div class="example"><p><code> - RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm - </code></p></div> + <pre class="prettyprint lang-config"> +RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm + </pre> + <p>The type can be sdbm, gdbm, ndbm or db. However, it is recommended that you just use the <a href="../programs/httxt2dbm.html">httxt2dbm</a> utility that is @@ -272,9 +273,10 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map <p>You can then reference the resulting file in your <code>RewriteMap</code> directive:</p> -<div class="example"><p><code> +<pre class="prettyprint lang-config"> RewriteMap mapname dbm:/etc/apache/mapfile.map -</code></p></div> +</pre> + <div class="note"> <p>Note that with some dbm types, more than one file is generated, with @@ -323,10 +325,13 @@ by many requests. the int function, and then use that in your <code>RewriteRule</code>: </p> - <div class="example"><h3>Redirect a URI to an all-lowercase version of itself</h3><p><code> - RewriteMap lc int:tolower<br /> - RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R] - </code></p></div> + <p> <strong>Redirect a URI to an all-lowercase version of itself</strong></p> + <pre class="prettyprint lang-config"> + +RewriteMap lc int:tolower +RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R] + </pre> + <div class="note"> <p>Please note that the example offered here is for @@ -365,22 +370,25 @@ by many requests. <p>A simple example is shown here which will replace all dashes with underscores in a request URI.</p> + +<p><strong>Rewrite configuration</strong></p> + <pre class="prettyprint lang-config"> - <div class="example"><h3>Rewrite configuration</h3><p><code> - RewriteMap d2u prg:/www/bin/dash2under.pl<br /> - RewriteRule - ${d2u:%{REQUEST_URI}} - </code></p></div> +RewriteMap d2u prg:/www/bin/dash2under.pl<br /> +RewriteRule - ${d2u:%{REQUEST_URI}} + </pre> + + + <p><strong>dash2under.pl</strong></p> + <pre class="prettyprint lang-perl"> + #!/usr/bin/perl + $| = 1; # Turn off I/O buffering + while (<STDIN>) { + s/-/_/g; # Replace dashes with underscores + print $_; + } + </pre> - <div class="example"><h3>dash2under.pl</h3><p><code> - #!/usr/bin/perl<br /> - $| = 1; # Turn off I/O buffering<br /> - while (<STDIN>) {<br /> - <span class="indent"> - s/-/_/g; # Replace dashes with underscores<br /> - print $_;<br /> - </span> - }<br /> - </code></p></div> <div class="note"><h3>Caution!</h3> <ul> @@ -422,9 +430,10 @@ this process, or if the script itself is very slow.</li> <p>If a query returns more than one row, a random row from the result set is used.</p> - <div class="example"><h3>Example</h3><p><code> + <div class="example"><h3>Example</h3><pre class="prettyprint lang-config"> RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s" - </code></p></div> + </pre> +</div> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> @@ -444,7 +453,28 @@ RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s" </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewritemap.html" title="English"> en </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/rewritemap.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/tech.html.en b/docs/manual/rewrite/tech.html.en index a05695db..05871513 100644 --- a/docs/manual/rewrite/tech.html.en +++ b/docs/manual/rewrite/tech.html.en @@ -8,10 +8,13 @@ <title>Apache mod_rewrite Technical Details - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -27,7 +30,7 @@ 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="#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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="InternalAPI" id="InternalAPI">API Phases</a></h2> @@ -144,7 +147,7 @@ and URL matching.</p> first, and so the control flow is a little bit long-winded. See Figure 1 for more details.</p> <p class="figure"> - <img src="../images/rewrite_rule_flow.png" alt="Flow of RewriteRule and RewriteCond matching" /><br /> + <img src="../images/rewrite_process_uri.png" alt="Flow of RewriteRule and RewriteCond matching" /><br /> <dfn>Figure 1:</dfn>The control flow through the rewriting ruleset </p> <p>First the URL is matched against the @@ -173,7 +176,28 @@ and URL matching.</p> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/tech.html" title="English"> en </a> | <a href="../fr/rewrite/tech.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/tech.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/tech.html.fr b/docs/manual/rewrite/tech.html.fr index bb070942..fa4b8602 100644 --- a/docs/manual/rewrite/tech.html.fr +++ b/docs/manual/rewrite/tech.html.fr @@ -8,10 +8,13 @@ <title>Détails techniques sur le module Apache mod_rewrite - Serveur Apache HTTP</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</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> <p class="apache">Serveur Apache HTTP Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -21,8 +24,6 @@ <p><span>Langues Disponibles: </span><a href="../en/rewrite/tech.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/tech.html" title="Français"> fr </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>Ce document passe en revue certains détails techniques à propos du module mod_rewrite et de la mise en correspondance des URLs</p> @@ -30,7 +31,7 @@ module mod_rewrite et de la mise en correspondance des URLs</p> <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></ul></div> +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></ul><ul class="seealso"><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></h2> @@ -160,7 +161,7 @@ correspondance</a></li><li><a href="access.html">Contrôle d'accès</a></li><li><a contrôle est un peu compliqué. Voir la figure 1 pour plus de détails.</p> <p class="figure"> - <img src="../images/rewrite_rule_flow.png" alt="Flux des comparaisons des directives RewriteRule et RewriteCond" /><br /> + <img src="../images/rewrite_process_uri.png" alt="Flux des comparaisons des directives RewriteRule et RewriteCond" /><br /> <dfn>Figure 1:</dfn>Déroulement du contrôle à travers le jeu de règles de réécriture </p> @@ -193,7 +194,28 @@ correspondance</a></li><li><a href="access.html">Contrôle d'accès</a></li><li><a <div class="bottomlang"> <p><span>Langues Disponibles: </span><a href="../en/rewrite/tech.html" hreflang="en" rel="alternate" title="English"> en </a> | <a href="../fr/rewrite/tech.html" title="Français"> fr </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/tech.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/vhosts.html.en b/docs/manual/rewrite/vhosts.html.en index dd509c46..9f9d0aa1 100644 --- a/docs/manual/rewrite/vhosts.html.en +++ b/docs/manual/rewrite/vhosts.html.en @@ -8,10 +8,13 @@ <title>Dynamic mass virtual hosts with mod_rewrite - Apache HTTP Server</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 href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<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> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -37,7 +40,7 @@ mod_rewrite</a> document.</div> <li><img alt="" src="../images/down.gif" /> <a href="#simple.rewrite">Dynamic Virtual Hosts Using <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></a></li> <li><img alt="" src="../images/down.gif" /> <a href="#xtra-conf">Using a Separate Virtual Host Configuration File</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="access.html">Controlling access</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="access.html">Controlling access</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><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> <div class="section"> <h2><a name="per-hostname" id="per-hostname">Virtual Hosts For Arbitrary Hostnames</a></h2> @@ -62,14 +65,15 @@ mod_rewrite</a> document.</div> <dd> -<div class="example"><p><code> -RewriteEngine on<br /> -<br /> -RewriteMap lowercase int:tolower<br /> -<br /> -RewriteCond %{lowercase:%{<strong>HTTP_HOST</strong>}} ^www\.<strong>([^.]+)</strong>\.example\.com$<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on + +RewriteMap lowercase int:tolower + +RewriteCond ${lowercase:%{<strong>HTTP_HOST</strong>}} ^www\.<strong>([^.]+)</strong>\.example\.com$ RewriteRule ^(.*) /home/<strong>%1</strong>/www$1 -</code></p></div></dd> +</pre> +</dd> <dt>Discussion</dt> <dd> @@ -119,39 +123,38 @@ dynamic content, and Alias resolution. any <code>ScriptAlias</code> directives, we must have <code>mod_rewrite</code> explicitly enact those mappings.</p> -<div class="example"><p><code> -# get the server name from the Host: header<br /> -UseCanonicalName Off<br /> -<br /> -# splittable logs<br /> -LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon<br /> -CustomLog logs/access_log vcommon<br /> -<br /> -<Directory /www/hosts><br /> -<span class="indent"> - # ExecCGI is needed here because we can't force<br /> - # CGI execution in the way that ScriptAlias does<br /> - Options FollowSymLinks ExecCGI<br /> -</span> -</Directory><br /> -<br /> -RewriteEngine On<br /> -<br /> -# a ServerName derived from a Host: header may be any case at all<br /> -RewriteMap lowercase int:tolower<br /> -<br /> -## deal with normal documents first:<br /> -# allow Alias /icons/ to work - repeat for other aliases<br /> -RewriteCond %{REQUEST_URI} !^/icons/<br /> -# allow CGIs to work<br /> -RewriteCond %{REQUEST_URI} !^/cgi-bin/<br /> -# do the magic<br /> -RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1<br /> -<br /> -## and now deal with CGIs - we have to force a handler<br /> -RewriteCond %{REQUEST_URI} ^/cgi-bin/<br /> -RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-script]<br /> -</code></p></div> +<pre class="prettyprint lang-config"> +# get the server name from the Host: header +UseCanonicalName Off + +# splittable logs +LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon +CustomLog logs/access_log vcommon + +<Directory /www/hosts> + # ExecCGI is needed here because we can't force + # CGI execution in the way that ScriptAlias does + Options FollowSymLinks ExecCGI +</Directory> + +RewriteEngine On + +# a ServerName derived from a Host: header may be any case at all +RewriteMap lowercase int:tolower + +## deal with normal documents first: +# allow Alias /icons/ to work - repeat for other aliases +RewriteCond %{REQUEST_URI} !^/icons/ +# allow CGIs to work +RewriteCond %{REQUEST_URI} !^/cgi-bin/ +# do the magic +RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1 + +## and now deal with CGIs - we have to force a handler +RewriteCond %{REQUEST_URI} ^/cgi-bin/ +RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-script] +</pre> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> @@ -174,32 +177,54 @@ customer-N.example.com /www/customers/N<br /> <p>The <code>httpd.conf</code> should contain the following:</p> -<div class="example"><p><code> -RewriteEngine on<br /> -<br /> -RewriteMap lowercase int:tolower<br /> -<br /> -# define the map file<br /> -RewriteMap vhost txt:/www/conf/vhost.map<br /> -<br /> -# deal with aliases as above<br /> -RewriteCond %{REQUEST_URI} !^/icons/<br /> -RewriteCond %{REQUEST_URI} !^/cgi-bin/<br /> -RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$<br /> -# this does the file-based remap<br /> -RewriteCond ${vhost:%1} ^(/.*)$<br /> -RewriteRule ^/(.*)$ %1/docs/$1<br /> -<br /> -RewriteCond %{REQUEST_URI} ^/cgi-bin/<br /> -RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$<br /> -RewriteCond ${vhost:%1} ^(/.*)$<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on + +RewriteMap lowercase int:tolower + +# define the map file +RewriteMap vhost txt:/www/conf/vhost.map + +# deal with aliases as above +RewriteCond %{REQUEST_URI} !^/icons/ +RewriteCond %{REQUEST_URI} !^/cgi-bin/ +RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ +# this does the file-based remap +RewriteCond ${vhost:%1} ^(/.*)$ +RewriteRule ^/(.*)$ %1/docs/$1 + +RewriteCond %{REQUEST_URI} ^/cgi-bin/ +RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ +RewriteCond ${vhost:%1} ^(/.*)$ RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script] -</code></p></div> +</pre> + </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/vhosts.html" title="English"> en </a></p> -</div><div id="footer"> +</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&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> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/vhosts.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<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(); +} +//--><!]]></script> </body></html>
\ No newline at end of file |