1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr"><head><!--
4        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5              This file is generated from xml source: DO NOT EDIT
6        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7      -->
8<title>Utilisation de mod_rewrite comme mandataire - Serveur Apache HTTP</title>
9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11<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" />
12<script src="/style/scripts/prettify.min.js" type="text/javascript">
13</script>
14
15<link href="/images/favicon.ico" rel="shortcut icon" /></head>
16<body id="manual-page"><div id="page-header">
17<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>
18<p class="apache">Serveur Apache HTTP Version 2.4</p>
19<img alt="" src="/images/feather.gif" /></div>
20<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
21<div id="path">
22<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">Serveur HTTP</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.4</a> &gt; <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Utilisation de mod_rewrite comme mandataire</h1>
23<div class="toplang">
24<p><span>Langues Disponibles: </span><a href="/en/rewrite/proxy.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
25<a href="/fr/rewrite/proxy.html" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
26</div>
27
28
29<p>Ce document est un compl�ment de la <a href="/mod/mod_rewrite.html">documentation de r�f�rence</a> du module
30<code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>. Il d�crit comment utiliser le drapeau [P]
31de la directive RewriteRule pour mandater un contenu vers un autre
32serveur. Plusieurs recettes d�crivant des sc�narios courants sont
33fournies.</p>
34
35</div>
36<div id="quickview"><h3>Voir aussi</h3><ul class="seealso"><li><a href="/mod/mod_rewrite.html">Documentation du module</a></li><li><a href="intro.html">Introduction � mod_rewrite</a></li><li><a href="remapping.html">Redirection et remise en
37correspondance</a></li><li><a href="access.html">Contr�le d'acc�s</a></li><li><a href="vhosts.html">Serveurs virtuels</a></li><li><a href="rewritemap.html">Utilisation de RewriteMap</a></li><li><a href="advanced.html">Techniques avanc�es</a></li><li><a href="avoid.html">Quand ne pas utiliser mod_rewrite</a></li></ul><ul class="seealso"><li><a href="#comments_section">Commentaires</a></li></ul></div>
38<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
39<div class="section">
40<h2><a name="dynamic-proxy" id="dynamic-proxy">Mandater du contenu avec mod_rewrite</a></h2>
41
42  
43
44  <dl>
45    <dt>Description :</dt>
46
47    <dd>
48    <p>
49    mod_rewrite impl�mente le drapeau [P] qui permet de passer des URLs,
50    via mod_proxy, � un autre serveur. Deux exemples sont fournis ici.
51    Dans le premier, une URL est pass�e directement � un autre serveur,
52    et servie comme si c'�tait une URL locale. Dans le deuxi�me, nous
53    mandatons un contenu manquant vers un serveur d'arri�re-plan.</p>
54    </dd>
55
56    <dt>Solution :</dt>
57
58    <dd>
59      <p>Pour passer une URL � un autre serveur, on utilise le drapeau
60      [P] comme suit :</p>
61
62<pre class="prettyprint lang-config">RewriteEngine  on
63RewriteBase    /produits/
64RewriteRule    ^widget/(.*)$  http://produits.example.com/widget/$1  [P]
65ProxyPassReverse /produits/objet/ http://produits.example.com/objet/</pre>
66
67
68   <p>Dans le deuxi�me exemple, nous ne mandatons la requ�te que si nous
69   ne trouvons pas la ressource localement. Ceci peut s'av�rer tr�s
70   utile lorsque vous effectuez une migration d'un serveur vers un
71   autre, et que vous n'�tes pas certain que tout le contenu a d�j� �t�
72   migr�.</p>
73
74<pre class="prettyprint lang-config">RewriteCond %{REQUEST_FILENAME}       !-f
75RewriteCond %{REQUEST_FILENAME}       !-d
76RewriteRule ^/(.*) http://ancien.exemple.com/$1 [P]
77ProxyPassReverse / http://ancien.exemple.com/</pre>
78
79    </dd>
80
81    <dt>Discussion :</dt>
82
83    <dd><p>Dans les deux cas, on ajoute une directive <code class="directive"><a href="/mod/mod_proxy.html#proxypassreverse">ProxyPassReverse</a></code> afin de s'assurer
84    que toute redirection en provenance du serveur d'arri�re-plan est
85    renvoy�e correctement au client.</p>
86
87    <p>Chaque fois que cela est possible, pr�f�rez l'utilisation de la
88    directive <code class="directive"><a href="/mod/mod_proxy.html#proxypass">ProxyPass</a></code> ou
89    <code class="directive"><a href="/mod/mod_proxy.html#proxypassmatch">ProxyPassMatch</a></code> �
90    mod_rewrite.</p>
91    </dd>
92  </dl>
93
94</div></div>
95<div class="bottomlang">
96<p><span>Langues Disponibles: </span><a href="/en/rewrite/proxy.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
97<a href="/fr/rewrite/proxy.html" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
98</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Commentaires</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
99<script type="text/javascript"><!--//--><![CDATA[//><!--
100var comments_shortname = 'httpd';
101var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/proxy.html';
102(function(w, d) {
103    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
104        d.write('<div id="comments_thread"><\/div>');
105        var s = d.createElement('script');
106        s.type = 'text/javascript';
107        s.async = true;
108        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
109        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
110    }
111    else { 
112        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
113    }
114})(window, document);
115//--><!]]></script></div><div id="footer">
116<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>
117<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[//><!--
118if (typeof(prettyPrint) !== 'undefined') {
119    prettyPrint();
120}
121//--><!]]></script>
122</body></html>