diff options
Diffstat (limited to 'docs/manual/rewrite')
27 files changed, 336 insertions, 604 deletions
diff --git a/docs/manual/rewrite/access.html.en b/docs/manual/rewrite/access.html.en index df312e6e..17f9a602 100644 --- a/docs/manual/rewrite/access.html.en +++ b/docs/manual/rewrite/access.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -79,31 +79,25 @@ configuration.</div> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_REFERER} !^$ +<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !www.example.com [NC] -RewriteRule \.(gif|jpg|png)$ - [F,NC] -</pre> +RewriteRule \.(gif|jpg|png)$ - [F,NC]</pre> <p>In this second example, instead of failing the request, we display an alternate image instead.</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_REFERER} !^$ +<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> +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> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_REFERER} !^$ +<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> +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 @@ -119,12 +113,10 @@ RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC] than redirecting that request elsewhere, this can be accomplished without the use of mod_rewrite:</p> - <pre class="prettyprint lang-config"> -SetEnvIf Referer example\.com localreferer + <pre class="prettyprint lang-config">SetEnvIf Referer example\.com localreferer <FilesMatch \.(jpg|png|gif)$> Require env localreferer -</FilesMatch> - </pre> +</FilesMatch></pre> </dd> </dl> @@ -168,11 +160,9 @@ SetEnvIf Referer example\.com localreferer range, if you are trying to block that user agent only from the particular source.</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot +<pre class="prettyprint lang-config">RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot RewriteCond %{REMOTE_ADDR} =123\.45\.67\.[8-9] -RewriteRule ^/secret/files/ - [F] -</pre> +RewriteRule ^/secret/files/ - [F]</pre> </dd> @@ -183,15 +173,13 @@ RewriteRule ^/secret/files/ - [F] Rather than using mod_rewrite for this, you can accomplish the same end using alternate means, as illustrated here: </p> - <pre class="prettyprint lang-config"> -SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway + <pre class="prettyprint lang-config">SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway <Location /secret/files> <RequireAll> Require all granted Require not env goaway </RequireAll> -</Location> - </pre> +</Location></pre> <p> As noted above, this technique is trivial to circumvent, by simply @@ -222,13 +210,11 @@ SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway <dt>Solution:</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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] -</pre> +RewriteRule ^ - [F]</pre> <div class="example"><p><code> @@ -277,8 +263,7 @@ bsdti1.sdm.de -<br /> <p>The following ruleset uses a map file to associate each Referer with a redirection target.</p> -<pre class="prettyprint lang-config"> -RewriteMap deflector txt:/path/to/deflector.map +<pre class="prettyprint lang-config">RewriteMap deflector txt:/path/to/deflector.map RewriteCond %{HTTP_REFERER} !="" RewriteCond ${deflector:%{HTTP_REFERER}} =- @@ -286,23 +271,20 @@ RewriteRule ^ %{HTTP_REFERER} [R,L] RewriteCond %{HTTP_REFERER} !="" RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND -RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L] -</pre> +RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]</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> -<pre class="prettyprint lang-config"> -##<br /> +<pre class="prettyprint lang-config">##<br /> ## deflector.map<br /> ##<br /> <br /> 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/ -</pre> +http://badguys.example.com/bad/index3.html http://somewhere.example.com/</pre> </dd> @@ -330,7 +312,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/access.html' } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/access.html.fr b/docs/manual/rewrite/access.html.fr index b23b3c8b..904257ae 100644 --- a/docs/manual/rewrite/access.html.fr +++ b/docs/manual/rewrite/access.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -80,31 +80,25 @@ correspondance</a></li><li><a href="vhosts.html">Serveurs virtuels</a></li><li>< -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_REFERER} !^$ +<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !www.example.com [NC] -RewriteRule \.(gif|jpg|png)$ - [F,NC] -</pre> +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> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_REFERER} !^$ +<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> +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} !^$ +<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> +RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC]</pre> <p>De tous ces exemples, les deux derniers semblent les plus @@ -121,12 +115,10 @@ RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC] simplement interdire l'accès à la ressource, vous pouvez y parvenir sans utiliser mod_rewrite :</p> - <pre class="prettyprint lang-config"> -SetEnvIf Referer example\.com localreferer + <pre class="prettyprint lang-config">SetEnvIf Referer example\.com localreferer <FilesMatch \.(jpg|png|gif)$> Require env localreferer -</FilesMatch> - </pre> +</FilesMatch></pre> </dd> </dl> @@ -172,11 +164,9 @@ SetEnvIf Referer example\.com localreferer seulement depuis une source particulière, vous pouvez aussi spécifier un intervalle d'adresses IP.</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot +<pre class="prettyprint lang-config">RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot RewriteCond %{REMOTE_ADDR} =123\.45\.67\.[8-9] -RewriteRule ^/secret/files/ - [F] -</pre> +RewriteRule ^/secret/files/ - [F]</pre> </dd> @@ -187,15 +177,13 @@ RewriteRule ^/secret/files/ - [F] Vous pouvez cependant parvenir au même résultat sans utiliser mod_rewrite via la méthode alternative suivante : </p> - <pre class="prettyprint lang-config"> -SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway + <pre class="prettyprint lang-config">SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway <Location /secret/files> <RequireAll> Require all granted Require not env goaway </RequireAll> -</Location> - </pre> +</Location></pre> <p> Comme indiqué plus haut, il est aisé de contourner cette @@ -227,13 +215,11 @@ SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway <dt>Solution :</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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] -</pre> +RewriteRule ^ - [F]</pre> <div class="example"><p><code> @@ -284,8 +270,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteMap deflector txt:/path/to/deflector.map +<pre class="prettyprint lang-config">RewriteMap deflector txt:/path/to/deflector.map RewriteCond %{HTTP_REFERER} !="" RewriteCond ${deflector:%{HTTP_REFERER}} =- @@ -293,8 +278,7 @@ RewriteRule ^ %{HTTP_REFERER} [R,L] RewriteCond %{HTTP_REFERER} !="" RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND -RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L] -</pre> +RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]</pre> <p>Le fichier de correspondances contient les cibles de @@ -302,15 +286,13 @@ RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L] simplement rediriger les requêtes vers leur Referer, un "-" est inscrit dans le fichier de correspondances :</p> -<pre class="prettyprint lang-config"> -##<br /> +<pre class="prettyprint lang-config">##<br /> ## deflector.map<br /> ##<br /> <br /> 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/ -</pre> +http://www.mauvais-gars.example.com/mauvais/index3.html http://quelque-part.example.com/</pre> </dd> @@ -338,7 +320,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/access.html' } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/advanced.html.en b/docs/manual/rewrite/advanced.html.en index 20d02ed8..685307f6 100644 --- a/docs/manual/rewrite/advanced.html.en +++ b/docs/manual/rewrite/advanced.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -21,8 +21,8 @@ <div id="path"> <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.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>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> +<p><span>Available Languages: </span><a href="../en/rewrite/advanced.html" title="English"> en </a> | +<a href="../fr/rewrite/advanced.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> </div> @@ -92,11 +92,9 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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> +RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2</pre> </dd> </dl> @@ -126,11 +124,9 @@ RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2 <dd> This is done via the following ruleset: -<pre class="prettyprint lang-config"> -# This example is valid in per-directory context only +<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] -</pre> +RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L]</pre> <p>The <code>-U</code> operator determines whether the test string @@ -168,11 +164,9 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on RewriteMap lb rnd:/path/to/serverlist.txt -RewriteRule ^/(.*) http://${lb:servers}/$1 [P,L] -</pre> +RewriteRule ^/(.*) http://${lb:servers}/$1 [P,L]</pre> <p><code>serverlist.txt</code> will contain a list of the servers:</p> @@ -224,9 +218,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1 -</pre> +<pre class="prettyprint lang-config">RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1</pre> <p>Now when we reference the URL</p> @@ -245,8 +237,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> -<pre class="prettyprint lang-perl"> -#!/sw/bin/perl +<pre class="prettyprint lang-perl">#!/sw/bin/perl ## ## nph-refresh -- NPH/CGI script for auto refreshing pages ## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved. @@ -346,8 +337,7 @@ for ( $n = 0 ; $n & lt ; $QS_n ; $n++ ) { exit(0); -##EOF## -</pre> +##EOF##</pre> </dd> </dl> @@ -377,10 +367,8 @@ exit(0); <p>We use the following ruleset to expand the tilde URLs into the above layout.</p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3 -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3</pre> </dd> </dl> @@ -437,13 +425,11 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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 -</pre> +RewriteRule ^foo\.html$ foo.night.html</pre> <p>This provides the content of <code>foo.day.html</code> @@ -483,18 +469,14 @@ RewriteRule ^foo\.html$ foo.night.html <dd> <p>Use the [E] flag to set an environment variable.</p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^/horse/(.*) /pony/$1 [E=<strong>rewritten:1</strong>] -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^/horse/(.*) /pony/$1 [E=<strong>rewritten:1</strong>]</pre> <p>Later in your ruleset you might check for this environment variable using a RewriteCond:</p> -<pre class="prettyprint lang-config"> -RewriteCond %{ENV:rewritten} =1 -</pre> +<pre class="prettyprint lang-config">RewriteCond %{ENV:rewritten} =1</pre> <p>Note that environment variables do not survive an external @@ -506,12 +488,12 @@ RewriteCond %{ENV:rewritten} =1 </div></div> <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> +<p><span>Available Languages: </span><a href="../en/rewrite/advanced.html" title="English"> en </a> | +<a href="../fr/rewrite/advanced.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p> </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&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'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/advanced.html'; (function(w, d) { if (w.location.hostname.toLowerCase() == "httpd.apache.org") { d.write('<div id="comments_thread"><\/div>'); @@ -526,7 +508,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/advanced.html.fr b/docs/manual/rewrite/advanced.html.fr index 054dea3e..9674584f 100644 --- a/docs/manual/rewrite/advanced.html.fr +++ b/docs/manual/rewrite/advanced.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -21,8 +21,8 @@ <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>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> +<p><span>Langues Disponibles: </span><a href="../en/rewrite/advanced.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/rewrite/advanced.html" title="Français"> fr </a></p> </div> @@ -101,11 +101,9 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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> +RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2</pre> </dd> </dl> @@ -136,11 +134,9 @@ RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2 <dd> A cet effet, on utilise le jeu de règles suivant : -<pre class="prettyprint lang-config"> -# Cet exemple n'est valable que dans un contexte de répertoire +<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] -</pre> +RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L]</pre> <p>L'opérateur <code>-U</code> permet de déterminer si la chaîne @@ -181,11 +177,9 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on RewriteMap lb rnd:/path/to/serverlist.txt -RewriteRule ^/(.*) http://${lb:serveurs}/$1 [P,L] -</pre> +RewriteRule ^/(.*) http://${lb:serveurs}/$1 [P,L]</pre> <p><code>liste-serveurs.txt</code> contiendra la liste des serveurs :</p> @@ -239,9 +233,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^(/[uge]/[^/]+/?.*):refresh /interne/cgi/apache/nph-refresh?f=$ -</pre> +<pre class="prettyprint lang-config">RewriteRule ^(/[uge]/[^/]+/?.*):refresh /interne/cgi/apache/nph-refresh?f=$</pre> <p>Nous appelons maintenant cette URL</p> @@ -260,8 +252,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> -<pre class="prettyprint lang-perl"> -#!/sw/bin/perl +<pre class="prettyprint lang-perl">#!/sw/bin/perl ## ## nph-refresh -- script NPH/CGI pour l'actualisation automatique de ## pages @@ -362,8 +353,7 @@ for ( $n = 0 ; $n & lt ; $QS_n ; $n++ ) { exit(0); -##EOF## -</pre> +##EOF##</pre> </dd> </dl> @@ -395,10 +385,8 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3 -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3</pre> </dd> </dl> @@ -458,12 +446,10 @@ RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</stro permettent d'effectuer des redirections dépendant de l'heure :</p> -<pre class="prettyprint lang-config"> -+RewriteEngine on +<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> ++RewriteRule ^foo\.html$ foo.day.html [L]</pre> <p>Avec cet exemple, l'URL <code>foo.html</code> renvoie @@ -506,19 +492,15 @@ RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</stro <p>Utiliser le drapeau [E] pour définir une variable d'environnement.</p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^/cheval/(.*) /poney/$1 [E=<strong>rewritten:1</strong>] -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^/cheval/(.*) /poney/$1 [E=<strong>rewritten:1</strong>]</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> -<pre class="prettyprint lang-config"> -RewriteCond %{ENV:rewritten} =1 -</pre> +<pre class="prettyprint lang-config">RewriteCond %{ENV:rewritten} =1</pre> </dd> @@ -526,12 +508,12 @@ RewriteCond %{ENV:rewritten} =1 </div></div> <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> +<p><span>Langues Disponibles: </span><a href="../en/rewrite/advanced.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/rewrite/advanced.html" title="Français"> fr </a></p> </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Commentaires</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&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'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/advanced.html'; (function(w, d) { if (w.location.hostname.toLowerCase() == "httpd.apache.org") { d.write('<div id="comments_thread"><\/div>'); @@ -546,7 +528,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/avoid.html.en b/docs/manual/rewrite/avoid.html.en index 5d76ed97..f50908cd 100644 --- a/docs/manual/rewrite/avoid.html.en +++ b/docs/manual/rewrite/avoid.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -90,8 +90,7 @@ and <code>/one/three/four.html</code>.</p> <p>To redirect <code>http</code> URLs to <code>https</code>, do the following:</p> -<pre class="prettyprint lang-config"> -<VirtualHost *:80> +<pre class="prettyprint lang-config"><VirtualHost *:80> ServerName www.example.com Redirect / https://www.example.com/ </VirtualHost > @@ -99,8 +98,7 @@ following:</p> <VirtualHost *:443> ServerName www.example.com # ... SSL configuration goes here -</VirtualHost > -</pre> +</VirtualHost ></pre> <p>The use of <code>RewriteRule</code> to perform this task may be @@ -166,27 +164,21 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P]</pre> <p>However, in many cases, when there is no actual pattern matching 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> -<pre class="prettyprint lang-config"> -ProxyPass /images/ http://imageserver.local/images/ -</pre> +<pre class="prettyprint lang-config">ProxyPass /images/ http://imageserver.local/images/</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> -<pre class="prettyprint lang-config"> -ProxyPassReverse /images/ http://imageserver.local/images/ -</pre> +<pre class="prettyprint lang-config">ProxyPassReverse /images/ http://imageserver.local/images/</pre> <p>You may need to use <code>RewriteRule</code> instead when there are @@ -209,11 +201,9 @@ 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> -<pre class="prettyprint lang-config"> -<If "req('Host') != 'www.example.com'"> +<pre class="prettyprint lang-config"><If "req('Host') != 'www.example.com'"> Redirect / http://www.example.com/ -</If> -</pre> +</If></pre> <p>This technique can be used to take actions based on any request @@ -246,7 +236,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/avoid.html.fr b/docs/manual/rewrite/avoid.html.fr index 1a6920a8..6c11a8bc 100644 --- a/docs/manual/rewrite/avoid.html.fr +++ b/docs/manual/rewrite/avoid.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -97,8 +97,7 @@ rediriger toutes les URLs de niveaux inférieurs comme <p>Pour rediriger les URLs <code>http</code> vers <code>https</code>, utilisez cette définition :</p> -<pre class="prettyprint lang-config"> -<VirtualHost *:80> +<pre class="prettyprint lang-config"><VirtualHost *:80> ServerName www.example.com Redirect / https://www.example.com/ </VirtualHost > @@ -106,8 +105,7 @@ Redirect / https://www.example.com/ <VirtualHost *:443> ServerName www.example.com # ... insérer ici la configuration SSL -</VirtualHost > -</pre> +</VirtualHost ></pre> <p>L'utilisation de la directive <code>RewriteRule</code> pour accomplir @@ -180,9 +178,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^/?images(.*) http://serveur-images.local/images$1 [P] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/?images(.*) http://serveur-images.local/images$1 [P]</pre> <p>Cependant, dans les nombreux cas où aucune correspondance au modèle @@ -190,18 +186,14 @@ 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> -<pre class="prettyprint lang-config"> -ProxyPass /images/ http://serveur-images.local/images/ -</pre> +<pre class="prettyprint lang-config">ProxyPass /images/ http://serveur-images.local/images/</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> -<pre class="prettyprint lang-config"> -ProxyPassReverse /images/ http://serveur-images.local/images/ -</pre> +<pre class="prettyprint lang-config">ProxyPassReverse /images/ http://serveur-images.local/images/</pre> <p>Vous devrez cependant tout de même utiliser <code>RewriteRule</code> @@ -225,11 +217,9 @@ 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> -<pre class="prettyprint lang-config"> -<If "req('Host') != 'www.example.com'"> +<pre class="prettyprint lang-config"><If "req('Host') != 'www.example.com'"> Redirect / http://www.example.com -</If> -</pre> +</If></pre> <p>On peut utiliser cette technique dans de nombreux scénarios courant @@ -264,7 +254,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/flags.html.en b/docs/manual/rewrite/flags.html.en index 1153c2ed..2ccaaf3a 100644 --- a/docs/manual/rewrite/flags.html.en +++ b/docs/manual/rewrite/flags.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -173,10 +173,8 @@ browsers that support this feature.</dd> <p>Consider this example:</p> -<pre class="prettyprint lang-config"> -RewriteEngine On -RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.com:1440:/] -</pre> +<pre class="prettyprint lang-config">RewriteEngine On +RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.com:1440:/]</pre> <p>In the example give, the rule doesn't rewrite the request. @@ -262,10 +260,8 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule \.(png|gif|jpg)$ - [E=image:1] -CustomLog logs/access_log combined env=!image -</pre> +<pre class="prettyprint lang-config">RewriteRule \.(png|gif|jpg)$ - [E=image:1] +CustomLog logs/access_log combined env=!image</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 @@ -336,9 +332,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source]</pre> <p>The regular expression above - <code>^(/source/.+\.php)s$</code> - will @@ -386,11 +380,9 @@ 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> -<pre class="prettyprint lang-config"> -RewriteBase / +<pre class="prettyprint lang-config">RewriteBase / RewriteCond %{REQUEST_URI} !=/index.php -RewriteRule ^(.*) /index.php?req=$1 [L,PT] -</pre> +RewriteRule ^(.*) /index.php?req=$1 [L,PT]</pre> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> @@ -406,15 +398,22 @@ certain string or letter repeatedly in a request. The example shown here will replace A with B everywhere in a request, and will continue doing so until there are no more As to be replaced. </p> - <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 <code>A</code>), perform this substitution (i.e., replace the <code>A</code> with a <code>B</code>).</p> +<p>In 2.4.8 and later, this module returns an error after 32,000 iterations to +protect against unintended looping. An alternative maximum number of +iterations can be specified by adding to the N flag. </p> +<pre class="prettyprint lang-config"># Be willing to replace 1 character in each pass of the loop +RewriteRule (.+)[><;]$ $1 [N=64000] +# ... or, give up if after 10 loops +RewriteRule (.+)[><;]$ $1 [N=10]</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_nc" id="flag_nc">NC|nocase</a></h2> @@ -536,10 +535,8 @@ use the [PT] flag to ensure that the <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> is evaluated. </p> -<pre class="prettyprint lang-config"> -Alias /icons /usr/local/apache/icons -RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT] -</pre> +<pre class="prettyprint lang-config">Alias /icons /usr/local/apache/icons +RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT]</pre> <p> @@ -638,22 +635,20 @@ URI in request' warnings. <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. The syntax of the skip flag is [S=<em>N</em>], where <em>N</em> signifies -the number of rules to skip (provided the <code class="directive"><a href="../mod/mod_rewrite.html# rewriterule"> +the number of rules to skip (provided the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule"> RewriteRule</a></code> matches). 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? +<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 -</pre> +RewriteRule (.*\.html) docs.php?$1</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 @@ -664,8 +659,7 @@ 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> -<pre class="prettyprint lang-config"> -# Does the file exist? +<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. @@ -678,8 +672,7 @@ RewriteRule .? - [S=3] RewriteRule .? - [S=1] # ELSE... RewriteRule (.*) 404.php?file=$1 -# END -</pre> +# END</pre> <p>It is probably easier to accomplish this kind of configuration using @@ -694,20 +687,16 @@ 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> -<pre class="prettyprint lang-config"> -# Serve .pl files as plain text -RewriteRule \.pl$ - [T=text/plain] -</pre> +<pre class="prettyprint lang-config"># Serve .pl files as plain text +RewriteRule \.pl$ - [T=text/plain]</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> -<pre class="prettyprint lang-config"> -# Files with 'IMG' in the name are jpg images. -RewriteRule IMG - [T=image/jpg] -</pre> +<pre class="prettyprint lang-config"># Files with 'IMG' in the name are jpg images. +RewriteRule IMG - [T=image/jpg]</pre> <p>Please note that this is a trivial example, and could be better done @@ -746,7 +735,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/flags.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/flags.html.fr b/docs/manual/rewrite/flags.html.fr index 2d163b83..00e83010 100644 --- a/docs/manual/rewrite/flags.html.fr +++ b/docs/manual/rewrite/flags.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -187,10 +187,8 @@ fonctionnalité.</dd> <p>Voici un exemple :</p> -<pre class="prettyprint lang-config"> -RewriteEngine On -RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.org:1440:/] -</pre> +<pre class="prettyprint lang-config">RewriteEngine On +RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.org:1440:/]</pre> <p>Dans l'exemple ci-dessus, la règle ne réécrit @@ -358,9 +356,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source]</pre> @@ -414,11 +410,9 @@ 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> -<pre class="prettyprint lang-config"> -RewriteBase / +<pre class="prettyprint lang-config">RewriteBase / RewriteCond %{REQUEST_URI} !=/index.php -RewriteRule ^(.*) /index.php?req=$1 [L,PT] -</pre> +RewriteRule ^(.*) /index.php?req=$1 [L,PT]</pre> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> @@ -445,6 +439,15 @@ dire, tant que l'URI contient un <code>A</code>), effectuer la substitution (c'est à dire, remplacer le <code>A</code> par un <code>B</code>).</p> +<p>A partir de la version 2.4.8, ce module renvoie une erreur après +32000 itérations afin d'éviter les boucles infinies. Ce nombre maximum +d'itération peut être modifié via le drapeau N.</p> +<pre class="prettyprint lang-config"># On veut remplacer 1 caractère à chaque itération de la boucle +RewriteRule (.+)[><;]$ $1 [N=64000] +# ... ou s'arrêter après 10 itérations +RewriteRule (.+)[><;]$ $1 [N=10]</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_nc" id="flag_nc">NC|nocase</a></h2> @@ -574,10 +577,8 @@ 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> -<pre class="prettyprint lang-config"> -Alias /icons /usr/local/apache/icons -RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT] -</pre> +<pre class="prettyprint lang-config">Alias /icons /usr/local/apache/icons +RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT]</pre> <p> @@ -688,16 +689,14 @@ 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> -<pre class="prettyprint lang-config"> -# La requête concerne-t-elle un fichier qui n'existe pas ? +<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 -</pre> +RewriteRule (.*\.html) docs.php?$1</pre> @@ -711,8 +710,7 @@ conditions et ajouter une <code>RewriteRule</code> avec le drapeau [Skip]. Cette 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> -<pre class="prettyprint lang-config"> -# Est-ce que le fichier existe ? +<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. @@ -725,8 +723,7 @@ RewriteRule (.*\.gif) images.php?$1 RewriteRule .? - [S=1] # ELSE... RewriteRule (.*) 404.php?file=$1 -# END -</pre> +# END</pre> <p>Il est probablement plus aisé de définir ce genre de configuration @@ -742,20 +739,16 @@ 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> -<pre class="prettyprint lang-config"> -# Sert les fichier .pl en tant que plein texte -RewriteRule \.pl$ - [T=text/plain] -</pre> +<pre class="prettyprint lang-config"># Sert les fichier .pl en tant que plein texte +RewriteRule \.pl$ - [T=text/plain]</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> -<pre class="prettyprint lang-config"> -# Les fichiers dont le nom contient 'IMG' sont des images jpg. -RewriteRule IMG - [T=image/jpg] -</pre> +<pre class="prettyprint lang-config"># Les fichiers dont le nom contient 'IMG' sont des images jpg. +RewriteRule IMG - [T=image/jpg]</pre> <p>Notez cependant qu'il s'agit d'un exemple trivial, et que le problème @@ -795,7 +788,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/flags.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/htaccess.html.en b/docs/manual/rewrite/htaccess.html.en index 31bb21f6..ea4633c9 100644 --- a/docs/manual/rewrite/htaccess.html.en +++ b/docs/manual/rewrite/htaccess.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -55,7 +55,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/htaccess.htm } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/htaccess.html.fr b/docs/manual/rewrite/htaccess.html.fr index a2a3fa83..b778a025 100644 --- a/docs/manual/rewrite/htaccess.html.fr +++ b/docs/manual/rewrite/htaccess.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -56,7 +56,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/htaccess.htm } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/index.html b/docs/manual/rewrite/index.html index 77d7eb5e..a5c3a448 100644 --- a/docs/manual/rewrite/index.html +++ b/docs/manual/rewrite/index.html @@ -12,6 +12,6 @@ URI: index.html.tr.utf8 Content-Language: tr Content-type: text/html; charset=UTF-8 -URI: index.html.zh-cn +URI: index.html.zh-cn.utf8 Content-Language: zh-cn Content-type: text/html; charset=UTF-8 diff --git a/docs/manual/rewrite/index.html.en b/docs/manual/rewrite/index.html.en index 1a7dc4d2..0e5653fc 100644 --- a/docs/manual/rewrite/index.html.en +++ b/docs/manual/rewrite/index.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -85,7 +85,7 @@ wiki</a></li><li><a href="../glossary.html">Glossary</a></li></ul></div> <a href="../tr/rewrite/" hreflang="tr" rel="alternate" 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 id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/index.html.fr b/docs/manual/rewrite/index.html.fr index 421b8a68..62594b76 100644 --- a/docs/manual/rewrite/index.html.fr +++ b/docs/manual/rewrite/index.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -99,7 +99,7 @@ avec le système de fichiers</a></li><li><a href="http://wiki.apache.org/httpd/Re <a href="../tr/rewrite/" hreflang="tr" rel="alternate" 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 id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/index.html.tr.utf8 b/docs/manual/rewrite/index.html.tr.utf8 index c536a7eb..f9a13521 100644 --- a/docs/manual/rewrite/index.html.tr.utf8 +++ b/docs/manual/rewrite/index.html.tr.utf8 @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -80,7 +80,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 id="footer"> -<p class="apache">Copyright 2013 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="apache">Copyright 2014 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="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(); diff --git a/docs/manual/rewrite/index.html.zh-cn b/docs/manual/rewrite/index.html.zh-cn.utf8 index ee5c409a..dafbefa2 100644 --- a/docs/manual/rewrite/index.html.zh-cn +++ b/docs/manual/rewrite/index.html.zh-cn.utf8 @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -69,7 +69,7 @@ wiki</a></li><li><a href="../glossary.html">术è¯</a></li></ul></div> <a href="../tr/rewrite/" hreflang="tr" rel="alternate" title="Türkçe"> tr </a> | <a href="../zh-cn/rewrite/" title="Simplified Chinese"> zh-cn </a></p> </div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />基于 <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> 许å¯è¯.</p> +<p class="apache">Copyright 2014 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="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(); diff --git a/docs/manual/rewrite/intro.html.en b/docs/manual/rewrite/intro.html.en index 83eeb8ed..e10c06e5 100644 --- a/docs/manual/rewrite/intro.html.en +++ b/docs/manual/rewrite/intro.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -189,9 +189,7 @@ value. <dl> <dt>A full filesystem path to a resource</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteRule ^/games /usr/local/games/web -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/games /usr/local/games/web</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> @@ -199,9 +197,7 @@ like the <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a> <dt>A web-path to a resource</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteRule ^/foo$ /bar -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/foo$ /bar</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 @@ -211,9 +207,7 @@ path <code>/usr/local/apache2/htdocs/bar</code>.</p> <dt>An absolute URL</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R]</pre> <p>This tells the client to make a new request for the specified URL.</p> </dd> @@ -222,9 +216,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1 -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1</pre> <p>The variable <code>$1</code> will be replaced with whatever text was matched by the expression inside the parenthesis in @@ -246,9 +238,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^puppy.html smalldog.html [NC] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^puppy.html smalldog.html [NC]</pre> <p>For more details on the available flags, their meanings, and @@ -273,10 +263,8 @@ argument is a list of flags that modify how the match is evaluated.</p> <p>For example, to send all requests from a particular IP range to a different server, you could use:</p> -<pre class="prettyprint lang-config"> -RewriteCond %{REMOTE_ADDR} ^10\.2\. -RewriteRule (.*) http://intranet.example.com$1 -</pre> +<pre class="prettyprint lang-config">RewriteCond %{REMOTE_ADDR} ^10\.2\. +RewriteRule (.*) http://intranet.example.com$1</pre> <p>When more than @@ -286,11 +274,9 @@ 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> -<pre class="prettyprint lang-config"> -RewriteCond %{QUERY_STRING} hack +<pre class="prettyprint lang-config">RewriteCond %{QUERY_STRING} hack RewriteCond %{HTTP_COOKIE} !go -RewriteRule . - [F] -</pre> +RewriteRule . - [F]</pre> <p>Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".</p> @@ -301,10 +287,8 @@ 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> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} (.*) -RewriteRule ^/(.*) /sites/%1/$1 -</pre> +<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} (.*) +RewriteRule ^/(.*) /sites/%1/$1</pre> <p>If the request was for <code>http://example.com/foo/bar</code>, then <code>%1</code> would contain <code>example.com</code> @@ -360,7 +344,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/intro.html.fr b/docs/manual/rewrite/intro.html.fr index 8cb25190..108cdfc5 100644 --- a/docs/manual/rewrite/intro.html.fr +++ b/docs/manual/rewrite/intro.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -213,9 +213,7 @@ trois types :</p> <dl> <dt>Un chemin complet du système de fichiers vers une ressource</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteRule ^/jeux /usr/local/jeux/web -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/jeux /usr/local/jeux/web</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> @@ -223,9 +221,7 @@ votre système de fichiers, un peu comme la directive <code class="directive"><a <dt>Un chemin web vers une ressource</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteRule ^/foo$ /bar -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/foo$ /bar</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 @@ -235,9 +231,7 @@ chemin <code>/usr/local/apache2/htdocs/bar</code>.</p> <dt>Une URL absolue</dt> <dd> -<pre class="prettyprint lang-config"> -RewriteRule ^/produits/vues$ http://site2.example.com/voirproduits.html [R] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/produits/vues$ http://site2.example.com/voirproduits.html [R]</pre> <p>Ceci informe le client qu'il doit effectuer une nouvelle requête vers l'URL spécifiée.</p> @@ -247,9 +241,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^/produits/(.*)/view$ /var/web/produitsdb/$1 -</pre> +<pre class="prettyprint lang-config">RewriteRule ^/produits/(.*)/view$ /var/web/produitsdb/$1</pre> <p>La variable <code>$1</code> sera remplacée par tout texte correspondant à l'expression située entre les parenthèses dans le @@ -270,9 +262,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteRule ^puppy.html petitchien.html [NC] -</pre> +<pre class="prettyprint lang-config">RewriteRule ^puppy.html petitchien.html [NC]</pre> <p>Pour une liste des drapeaux disponibles, leurs significations, et des @@ -299,10 +289,8 @@ 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> -<pre class="prettyprint lang-config"> -RewriteCond %{REMOTE_ADDR} ^10\.2\. -RewriteRule (.*) http://intranet.example.com$1 -</pre> +<pre class="prettyprint lang-config">RewriteCond %{REMOTE_ADDR} ^10\.2\. +RewriteRule (.*) http://intranet.example.com$1</pre> <p>Si vous spécifiez plus d'une directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>, ces directives @@ -310,11 +298,9 @@ doivent toutes être satisfaites pour que la règle <code class="directive"><a hre pour interdire les requêtes qui contiennent le mot "hack" dans la chaîne de requête, sauf si elles contiennent aussi un cookie contenant le mot "go", vous pouvez utiliser :</p> -<pre class="prettyprint lang-config"> -RewriteCond %{QUERY_STRING} hack +<pre class="prettyprint lang-config">RewriteCond %{QUERY_STRING} hack RewriteCond %{HTTP_COOKIE} !go -RewriteRule . - [F] -</pre> +RewriteRule . - [F]</pre> <p>Notez que le point d'exclamation indique une correspondance négative ; ainsi, la règle n'est appliquée que si le cookie ne contient pas "go"</p> @@ -326,10 +312,8 @@ 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> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} (.*) -RewriteRule ^/(.*) /sites/%1/$1 -</pre> +<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} (.*) +RewriteRule ^/(.*) /sites/%1/$1</pre> <p>Si la requête concernait <code>http://example.com/foo/bar</code>, alors <code>%1</code> contiendrait <code>example.com</code> et @@ -387,7 +371,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/intro.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/proxy.html.en b/docs/manual/rewrite/proxy.html.en index cc6077b1..0d3b1723 100644 --- a/docs/manual/rewrite/proxy.html.en +++ b/docs/manual/rewrite/proxy.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -57,12 +57,10 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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/ -</pre> +ProxyPassReverse /products/widget/ http://product.example.com/widget/</pre> <p>In the second example, we proxy the request only if we can't find @@ -70,12 +68,10 @@ ProxyPassReverse /products/widget/ http://product.example.com/widget/ from one server to another, and you're not sure if all the content has been migrated yet.</p> -<pre class="prettyprint lang-config"> -RewriteCond %{REQUEST_FILENAME} !-f +<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/ -</pre> +ProxyPassReverse / http://old.example.com/</pre> </dd> @@ -112,7 +108,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/proxy.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/proxy.html.fr b/docs/manual/rewrite/proxy.html.fr index 41350b03..b27f997b 100644 --- a/docs/manual/rewrite/proxy.html.fr +++ b/docs/manual/rewrite/proxy.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -59,12 +59,10 @@ correspondance</a></li><li><a href="access.html">Contrôle d'accès</a></li><li><a <p>Pour passer une URL à un autre serveur, on utilise le drapeau [P] comme suit :</p> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on RewriteBase /produits/ RewriteRule ^widget/(.*)$ http://produits.example.com/widget/$1 [P] -ProxyPassReverse /produits/objet/ http://produits.example.com/objet/ -</pre> +ProxyPassReverse /produits/objet/ http://produits.example.com/objet/</pre> <p>Dans le deuxième exemple, nous ne mandatons la requête que si nous @@ -73,12 +71,10 @@ ProxyPassReverse /produits/objet/ http://produits.example.com/objet/ autre, et que vous n'êtes pas certain que tout le contenu a déjà été migré.</p> -<pre class="prettyprint lang-config"> -RewriteCond %{REQUEST_FILENAME} !-f +<pre class="prettyprint lang-config">RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/(.*) http://ancien.exemple.com/$1 [P] -ProxyPassReverse / http://ancien.exemple.com/ -</pre> +ProxyPassReverse / http://ancien.exemple.com/</pre> </dd> @@ -117,7 +113,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/proxy.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/remapping.html.en b/docs/manual/rewrite/remapping.html.en index f2cc2014..7bdc1449 100644 --- a/docs/manual/rewrite/remapping.html.en +++ b/docs/manual/rewrite/remapping.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -75,10 +75,8 @@ configuration.</div> <p>We rewrite the old URL to the new one internally via the following rule:</p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT] -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT]</pre> </dd> </dl> @@ -107,10 +105,8 @@ RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</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> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<strong>R</strong>] -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<strong>R</strong>]</pre> </dd> @@ -151,18 +147,15 @@ RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<stron <pre class="prettyprint lang-config">#With mod_rewrite RewriteEngine on -RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L] -</pre> +RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L]</pre> <pre class="prettyprint lang-config">#With RedirectMatch -RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1 -</pre> +RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1</pre> <pre class="prettyprint lang-config">#With Redirect -Redirect /docs/ http://new.example.com/docs/ -</pre> +Redirect /docs/ http://new.example.com/docs/</pre> </dd> </dl> @@ -193,11 +186,9 @@ Redirect /docs/ http://new.example.com/docs/ internally leads to the invocation of <code>/~quux/foo.cgi</code>.</p> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on RewriteBase /~quux/ -RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] -</pre> +RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>]</pre> </dd> </dl> @@ -225,8 +216,7 @@ RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] existence of the new extension. If it exists, we take that name, else we rewrite the URL to its original state.</p> -<pre class="prettyprint lang-config"> -# backward compatibility ruleset for +<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> @@ -236,8 +226,7 @@ RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] RewriteCond $1.php -f RewriteCond $1.html !-f RewriteRule ^(.*).html$ $1.php -</Directory> -</pre> +</Directory></pre> </dd> @@ -285,8 +274,7 @@ 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> -<pre class="prettyprint lang-config"> -<VirtualHost *:80> +<pre class="prettyprint lang-config"><VirtualHost *:80> ServerName undesired.example.com ServerAlias example.com notthis.example.com @@ -295,29 +283,24 @@ hostname(s).</p> <VirtualHost *:80> ServerName www.example.com -</VirtualHost> -</pre> +</VirtualHost></pre> <p>You can alternatively accomplish this using the <code class="directive"><a href="../mod/core.html#if"><If></a></code> directive:</p> -<pre class="prettyprint lang-config"> -<If "%{HTTP_HOST} != 'www.example.com'"> +<pre class="prettyprint lang-config"><If "%{HTTP_HOST} != 'www.example.com'"> Redirect / http://www.example.com/ -</If> -</pre> +</If></pre> <p>Or, for example, to redirect a portion of your site to HTTPS, you might do the following:</p> -<pre class="prettyprint lang-config"> -<If "%{SERVER_PROTOCOL} != 'HTTPS'"> +<pre class="prettyprint lang-config"><If "%{SERVER_PROTOCOL} != 'HTTPS'"> Redirect /admin/ https://www.example.com/admin/ -</If> -</pre> +</If></pre> <p>If, for whatever reason, you still want to use <code>mod_rewrite</code> @@ -325,20 +308,16 @@ might do the following:</p> you might use one of the recipes below.</p> <p>For sites running on a port other than 80:</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] +<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] -</pre> +RewriteRule ^/?(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R,NE]</pre> <p>And for a site running on port 80</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] +<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteCond %{HTTP_HOST} !^$ -RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE] -</pre> +RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE]</pre> <p> @@ -348,11 +327,9 @@ RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE] <strong>example.com</strong>, you could use the following recipe:</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} !^www\. [NC] +<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} !^$ -RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] -</pre> +RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]</pre> <p>These rulesets will work either in your main server configuration @@ -383,8 +360,7 @@ 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> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on # first try to find it in dir1/... # ...and if found stop and be happy: @@ -398,8 +374,7 @@ RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L] # else go on for other Alias or ScriptAlias directives, # etc. -RewriteRule ^ - [PT] -</pre> +RewriteRule ^ - [PT]</pre> </dd> </dl> @@ -428,13 +403,11 @@ 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> -<pre class="prettyprint lang-config"> -HostnameLookups on +<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] -</pre> +RewriteRule ^/(.*)$ ${multiplex:<strong>%1</strong>|http://www.example.com/}$1 [R,L]</pre> <div class="example"><p><code> @@ -489,16 +462,14 @@ com http://www.example.com/<br /> All other browsers receive page <code>foo.32.html</code>. This is done with the following ruleset:</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_USER_AGENT} ^<strong>Mozilla/3</strong>.* +<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>] -</pre> +RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L</strong>]</pre> </dd> </dl> @@ -539,7 +510,7 @@ RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L This should really be accomplished with Redirect or RedirectMatch directives: - <pre class="prettyprint lang-config"> RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2 </pre> + <pre class="prettyprint lang-config">RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2</pre> </dd> </dl> @@ -569,10 +540,8 @@ using the following ruleset:</p> <code>/about/</code>: </p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^/$ /about/ [<strong>R</strong>] -</pre> +<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> @@ -606,26 +575,22 @@ 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> -<pre class="prettyprint lang-config"> -<Directory /var/www/my_blog> +<pre class="prettyprint lang-config"><Directory /var/www/my_blog> FallbackResource index.php -</Directory> -</pre> +</Directory></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> -<pre class="prettyprint lang-config"> -<Directory /var/www/my_blog> +<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> -</pre> +</Directory></pre> <p>If, on the other hand, you wish to pass the requested URI as a query @@ -663,7 +628,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/remapping.ht } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/remapping.html.fr b/docs/manual/rewrite/remapping.html.fr index 14a53222..de195659 100644 --- a/docs/manual/rewrite/remapping.html.fr +++ b/docs/manual/rewrite/remapping.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -77,10 +77,8 @@ copier/coller dans vos fichiers de configuration.</div> <p>On réécrit l'ancienne URL en interne vers la nouvelle via la règle suivante :</p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT] -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT]</pre> </dd> </dl> @@ -111,10 +109,8 @@ RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT] entraîne une modification de celle du navigateur et aussi de ce que voit l'utilisateur :</p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^<strong>foo</strong>\.html$ <strong>bar</strong>.html [<strong>R</strong>] -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^<strong>foo</strong>\.html$ <strong>bar</strong>.html [<strong>R</strong>]</pre> </dd> @@ -156,18 +152,15 @@ RewriteRule ^<strong>foo</strong>\.html$ <strong>bar</strong>.html [<strong <pre class="prettyprint lang-config">#Avec mod_rewrite RewriteEngine on -RewriteRule ^/docs/(.+) http://nouveau.example.com/docs/$1 [R,L] -</pre> +RewriteRule ^/docs/(.+) http://nouveau.example.com/docs/$1 [R,L]</pre> <pre class="prettyprint lang-config">#Avec RedirectMatch -RedirectMatch ^/docs/(.*) http://nouveau.example.com/docs/$1 -</pre> +RedirectMatch ^/docs/(.*) http://nouveau.example.com/docs/$1</pre> <pre class="prettyprint lang-config">#Avec Redirect -Redirect /docs/ http://nouveau.example.com/docs/ -</pre> +Redirect /docs/ http://nouveau.example.com/docs/</pre> </dd> </dl> @@ -198,11 +191,9 @@ Redirect /docs/ http://nouveau.example.com/docs/ en interne à l'invocation de <code>/~quux/foo.cgi</code>.</p> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on RewriteBase /~quux/ -RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] -</pre> +RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>]</pre> </dd> </dl> @@ -235,8 +226,7 @@ RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] réécrit l'URL sous sa forme originale.</p> -<pre class="prettyprint lang-config"> -# jeu de règles assurant une compatibilité ascendante en réécrivant<br /> +<pre class="prettyprint lang-config"># jeu de règles assurant une compatibilité ascendante en réécrivant<br /> # document.html en document.php si et seulement si document.php<br /> # existe <Directory /var/www/htdocs> @@ -246,8 +236,7 @@ RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] RewriteCond $1.php -f RewriteCond $1.html !-f RewriteRule ^(.*).html$ $1.php -</Directory> -</pre> +</Directory></pre> </dd> @@ -295,8 +284,7 @@ RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>] plutôt la directive <code class="directive"><a href="../mod/mod_alias.html#redirect">Redirect</a></code> dans une section de serveur virtuel pour le/les noms d'hôte non canoniques.</p> -<pre class="prettyprint lang-config"> -<VirtualHost *:80> +<pre class="prettyprint lang-config"><VirtualHost *:80> ServerName undesired.example.com ServerAlias example.com notthis.example.com @@ -305,27 +293,22 @@ une section de serveur virtuel pour le/les noms d'hôte non canoniques.</p> <VirtualHost *:80> ServerName www.example.com -</VirtualHost> -</pre> +</VirtualHost></pre> <p>Vous pouvez aussi utiliser la directive <code class="directive"><a href="../mod/core.html#if"><If></a></code> :</p> -<pre class="prettyprint lang-config"> -<If "%{HTTP_HOST} != 'www.example.com'"> +<pre class="prettyprint lang-config"><If "%{HTTP_HOST} != 'www.example.com'"> Redirect / http://www.example.com/ -</If> -</pre> +</If></pre> <p>Ou, par exemple, pour rediriger une portion de votre site vers HTTPS :</p> -<pre class="prettyprint lang-config"> -<If "%{SERVER_PROTOCOL} != 'HTTPS'"> +<pre class="prettyprint lang-config"><If "%{SERVER_PROTOCOL} != 'HTTPS'"> Redirect /admin/ https://www.example.com/admin/ -</If> -</pre> +</If></pre> <p>Si, pour une raison particulière, vous voulez tout de même utiliser @@ -334,20 +317,16 @@ d'un jeu plus important de règles de réécritures - vous pouvez utiliser la recette suivante :</p> <p>Pour les sites écoutant sur un port autre que 80:</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] +<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] -</pre> +RewriteRule ^/?(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R,NE]</pre> <p>Et pour un site écoutant sur le port 80</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] +<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteCond %{HTTP_HOST} !^$ -RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE] -</pre> +RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE]</pre> <p> Si vous souhaitez que cette règle s'applique à tous les noms de @@ -357,11 +336,9 @@ RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE] possibles de <strong>example.com</strong>, vous pouvez utiliser le jeu de règles suivants :</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_HOST} !^www\. [NC] +<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} !^$ -RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] -</pre> +RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]</pre> <p> Vous pouvez utiliser ce jeu de règles aussi bien dans le fichier @@ -396,8 +373,7 @@ RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] simplement de la servir à partir de l'adresse fournie dans la requête.</p> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on # on cherche tout d'abord dans dir1/... # ... et si on trouve, on est content et on arrête : @@ -411,8 +387,7 @@ RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L] # sinon, on continue la recherche avec d'autres directives Alias # ou ScriptAlias, etc... -RewriteRule ^ - [PT] -</pre> +RewriteRule ^ - [PT]</pre> </dd> </dl> @@ -442,13 +417,11 @@ RewriteRule ^ - [PT] <p>Nous allons utiliser une directive <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> afin de construire une liste des serveurs que nous voulons utiliser.</p> -<pre class="prettyprint lang-config"> -HostnameLookups on +<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] -</pre> +RewriteRule ^/(.*)$ ${multiplex:<strong>%1</strong>|http://www.example.com/}$1 [R,L]</pre> <div class="example"><p><code> @@ -501,16 +474,14 @@ com http://www.example.com/<br /> <code>foo.20.html</code>. Tous les autres navigateurs reçoivent la page <code>foo.32.html</code>. Tout ceci est effectué par le jeu de règles suivant :</p> -<pre class="prettyprint lang-config"> -RewriteCond %{HTTP_USER_AGENT} ^<strong>Mozilla/3</strong>.* +<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>] -</pre> +RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L</strong>]</pre> </dd> </dl> @@ -550,7 +521,7 @@ RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L <dd>On serait mieux inspiré d'utiliser ici les directives Redirect ou RedirectMatch : - <pre class="prettyprint lang-config"> RedirectMatch ^/(matous|minettes)/(.*) /chats/$2 </pre> + <pre class="prettyprint lang-config">RedirectMatch ^/(matous|minettes)/(.*) /chats/$2</pre> </dd> </dl> @@ -581,10 +552,8 @@ suivant :</p> <code>/a-propos-de/</code> : </p> -<pre class="prettyprint lang-config"> -RewriteEngine on -RewriteRule ^/$ /a-propos-de/ [<strong>R</strong>] -</pre> +<pre class="prettyprint lang-config">RewriteEngine on +RewriteRule ^/$ /a-propos-de/ [<strong>R</strong>]</pre> <p>Notez que l'on peut aussi y parvenir en utilisant la directive @@ -623,26 +592,22 @@ existant effectivement comme une image, ou un fichier css.</dd> <p>Depuis la version 2.2.16, vous pouvez y parvenir via la directive <code class="directive"><a href="../mod/mod_dir.html#fallbackresource">FallbackResource</a></code> :</p> -<pre class="prettyprint lang-config"> -<Directory /var/www/my_blog> +<pre class="prettyprint lang-config"><Directory /var/www/my_blog> FallbackResource index.php -</Directory> -</pre> +</Directory></pre> <p>Cependant, si vos besoins étaient plus complexes, vous pouviez, dans les versions plus anciennes d'Apache, utiliser un jeu de règles du style :</p> -<pre class="prettyprint lang-config"> -<Directory /var/www/my_blog> +<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> -</pre> +</Directory></pre> <p>D'autre part, si vous voulez transmettre l'URI de la requête en tant @@ -682,7 +647,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/remapping.ht } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/rewritemap.html.en b/docs/manual/rewrite/rewritemap.html.en index 71b983a5..89347eed 100644 --- a/docs/manual/rewrite/rewritemap.html.en +++ b/docs/manual/rewrite/rewritemap.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -143,10 +143,8 @@ may be used, and give examples of each.</p> 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> + <pre class="prettyprint lang-config">RewriteMap product2id txt:/etc/apache2/productmap.txt +RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre> <p>We assume here that the <code>prods.php</code> script knows what @@ -216,12 +214,10 @@ 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 + <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> +RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]</pre> <p>So, when an image is requested and the first of these rules is @@ -253,9 +249,7 @@ static www1|www1|www2|www3|www4 <p>You may optionally specify a particular dbm type:</p> - <pre class="prettyprint lang-config"> -RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm - </pre> + <pre class="prettyprint lang-config">RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm</pre> <p>The type can be sdbm, gdbm, ndbm or db. @@ -274,9 +268,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map <p>You can then reference the resulting file in your <code>RewriteMap</code> directive:</p> -<pre class="prettyprint lang-config"> -RewriteMap mapname dbm:/etc/apache/mapfile.map -</pre> +<pre class="prettyprint lang-config">RewriteMap mapname dbm:/etc/apache/mapfile.map</pre> <div class="note"> @@ -327,11 +319,8 @@ by many requests. </p> <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> + <pre class="prettyprint lang-config">RewriteMap lc int:tolower +RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]</pre> <div class="note"> @@ -373,22 +362,17 @@ RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R] underscores in a request URI.</p> <p><strong>Rewrite configuration</strong></p> - <pre class="prettyprint lang-config"> - -RewriteMap d2u prg:/www/bin/dash2under.pl<br /> -RewriteRule - ${d2u:%{REQUEST_URI}} - </pre> + <pre class="prettyprint lang-config">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 + <pre class="prettyprint lang-perl"> #!/usr/bin/perl $| = 1; # Turn off I/O buffering while (<STDIN>) { s/-/_/g; # Replace dashes with underscores print $_; - } - </pre> + }</pre> <div class="note"><h3>Caution!</h3> @@ -431,9 +415,7 @@ 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><pre class="prettyprint lang-config"> -RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s" - </pre> + <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s"</pre> </div> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> @@ -473,7 +455,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/rewritemap.h } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/rewritemap.html.fr b/docs/manual/rewrite/rewritemap.html.fr index 6c84d11b..294216a0 100644 --- a/docs/manual/rewrite/rewritemap.html.fr +++ b/docs/manual/rewrite/rewritemap.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -158,10 +158,8 @@ exemples pour chacun d'entre eux.</p> utilisant la recette suivante :</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> + <pre class="prettyprint lang-config">RewriteMap product2id txt:/etc/apache2/productmap.txt +RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre> <p>Nous supposons ici que le script <code>prods.php</code> sait quoi @@ -237,12 +235,10 @@ statique www1|www2|www3|www4<br /> dynamique www5|www6 </code></p></div> <p><strong>Directives de configuration</strong></p> - <pre class="prettyprint lang-config"> -RewriteMap servers rnd:/path/to/file/map.txt + <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> +RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]</pre> @@ -277,9 +273,7 @@ statique www1|www1|www2|www3|www4 <p>Vous pouvez éventuellement spécifier un type dbm particulier :</p> - <pre class="prettyprint lang-config"> -RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm - </pre> + <pre class="prettyprint lang-config">RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm</pre> <p>Ce type peut être choisi parmi sdbm, gdbm, ndbm ou db. Il est @@ -297,9 +291,7 @@ $ httxt2dbm -i fichier-map.txt -o fichier-map.map <p>Vous pouvez alors faire référence au fichier obtenu dans votre directive <code>RewriteMap</code> :</p> -<pre class="prettyprint lang-config"> -RewriteMap mapname dbm:/etc/apache/mapfile.map -</pre> +<pre class="prettyprint lang-config">RewriteMap mapname dbm:/etc/apache/mapfile.map</pre> <div class="note"> @@ -353,11 +345,8 @@ directive <code>RewriteMap</code>.</p> </p> <p> <strong>Redirige un URI vers son équivalent en minuscules</strong></p> - <pre class="prettyprint lang-config"> - -RewriteMap lc int:tolower -RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R] - </pre> + <pre class="prettyprint lang-config">RewriteMap lc int:tolower +RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]</pre> <div class="note"> @@ -401,22 +390,17 @@ RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R] caractères de soulignement dans l'URI de la requête.</p> <p><strong>Configuration de la réécriture</strong></p> - <pre class="prettyprint lang-config"> - -RewriteMap d2u prg:/www/bin/dash2under.pl<br /> -RewriteRule - ${d2u:%{REQUEST_URI}} - </pre> + <pre class="prettyprint lang-config">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 + <pre class="prettyprint lang-perl"> #!/usr/bin/perl $| = 1; # Turn off I/O buffering while (<STDIN>) { s/-/_/g; # Remplace tous les tirets par des caractères de soulignement print $_; - } - </pre> + }</pre> <div class="note"><h3>Mises en garde !</h3> @@ -463,9 +447,7 @@ script lui-même est très lent.</li> <p>Si une requête renvoie plusieurs enregistrements, un de ceux-ci sera sélectionné aléatoirement.</p> - <div class="example"><h3>Exemple</h3><pre class="prettyprint lang-config"> -RewriteMap ma-requete "fastdbd:SELECT destination FROM rewrite WHERE source = %s" - </pre> + <div class="example"><h3>Exemple</h3><pre class="prettyprint lang-config">RewriteMap ma-requete "fastdbd:SELECT destination FROM rewrite WHERE source = %s"</pre> </div> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> @@ -505,7 +487,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/rewritemap.h } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/tech.html.en b/docs/manual/rewrite/tech.html.en index 4a669fe1..dc4711de 100644 --- a/docs/manual/rewrite/tech.html.en +++ b/docs/manual/rewrite/tech.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -194,7 +194,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/tech.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/tech.html.fr b/docs/manual/rewrite/tech.html.fr index 93b66a35..17256601 100644 --- a/docs/manual/rewrite/tech.html.fr +++ b/docs/manual/rewrite/tech.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -212,7 +212,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/tech.html'; } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/vhosts.html.en b/docs/manual/rewrite/vhosts.html.en index 4fc45653..7ce23d0c 100644 --- a/docs/manual/rewrite/vhosts.html.en +++ b/docs/manual/rewrite/vhosts.html.en @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -66,14 +66,12 @@ mod_rewrite</a> document.</div> <dd> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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 -</pre> +RewriteRule ^(.*) /home/<strong>%1</strong>/www$1</pre> </dd> <dt>Discussion</dt> @@ -124,8 +122,7 @@ dynamic content, and Alias resolution. any <code>ScriptAlias</code> directives, we must have <code>mod_rewrite</code> explicitly enact those mappings.</p> -<pre class="prettyprint lang-config"> -# get the server name from the Host: header +<pre class="prettyprint lang-config"># get the server name from the Host: header UseCanonicalName Off # splittable logs @@ -153,8 +150,7 @@ 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> +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> @@ -178,8 +174,7 @@ customer-N.example.com /www/customers/N<br /> <p>The <code>httpd.conf</code> should contain the following:</p> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on RewriteMap lowercase int:tolower @@ -197,8 +192,7 @@ RewriteRule ^/(.*)$ %1/docs/$1 RewriteCond %{REQUEST_URI} ^/cgi-bin/ RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ RewriteCond ${vhost:%1} ^(/.*)$ -RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script] -</pre> +RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script]</pre> </div></div> @@ -223,7 +217,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/vhosts.html' } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); diff --git a/docs/manual/rewrite/vhosts.html.fr b/docs/manual/rewrite/vhosts.html.fr index bf4dcbce..368d5c7a 100644 --- a/docs/manual/rewrite/vhosts.html.fr +++ b/docs/manual/rewrite/vhosts.html.fr @@ -9,7 +9,7 @@ <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> -<script src="../style/scripts/prettify.js" type="text/javascript"> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> </script> <link href="../images/favicon.ico" rel="shortcut icon" /></head> @@ -70,14 +70,12 @@ correspondance</a></li><li><a href="access.html">Contrôle d'accès</a></li><li><a <dd> -<pre class="prettyprint lang-config"> -RewriteEngine on +<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 -</pre> +RewriteRule ^(.*) /home/<strong>%1</strong>/www$1</pre> </dd> <dt>Discussion</dt> @@ -132,8 +130,7 @@ virtuels via <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite< faire en sorte que <code>mod_rewrite</code> déclare explicitement ces correspondances.</p> -<pre class="prettyprint lang-config"> -# extrait le nom de serveur de l'en-tête Host: +<pre class="prettyprint lang-config"># extrait le nom de serveur de l'en-tête Host: UseCanonicalName Off # journaux dissociables @@ -162,8 +159,7 @@ RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1 ## on s'occupe maintenant des CGIs - on doit forcer l'utilisation d'un # gestionnaire RewriteCond %{REQUEST_URI} ^/cgi-bin/ -RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-script] -</pre> +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> @@ -188,8 +184,7 @@ www.client-N.example.com /www/clients/N<br /> <p>On doit ajouter à <code>httpd.conf</code> :</p> -<pre class="prettyprint lang-config"> -RewriteEngine on +<pre class="prettyprint lang-config">RewriteEngine on RewriteMap lowercase int:tolower @@ -207,8 +202,7 @@ RewriteRule ^/(.*)$ %1/docs/$1 RewriteCond %{REQUEST_URI} ^/cgi-bin/ RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ RewriteCond ${vhost:%1} ^(/.*)$ -RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script] -</pre> +RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script]</pre> </div></div> @@ -233,7 +227,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/vhosts.html' } })(window, document); //--><!]]></script></div><div id="footer"> -<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- if (typeof(prettyPrint) !== 'undefined') { prettyPrint(); |