|
27 | 27 |
|
28 | 28 | <summary> |
29 | 29 |
|
30 | | -<p>This document supplements the <module>mod_rewrite</module> |
31 | | -<a href="../mod/mod_rewrite.html">reference documentation</a>. It describes |
32 | | -how to use the RewriteRule's [P] flag to proxy content to another server. |
33 | | -A number of recipes are provided that describe common scenarios.</p> |
| 30 | +<note type="warning">This document has been deprecated. Its content has |
| 31 | +been merged into the |
| 32 | +<a href="avoid.html#proxy">When not to use mod_rewrite</a> document, |
| 33 | +since simple proxying is better accomplished using |
| 34 | +<directive module="mod_proxy">ProxyPass</directive>. This page will be |
| 35 | +removed in a future version of this documentation.</note> |
34 | 36 |
|
35 | 37 | </summary> |
36 | | -<seealso><a href="../mod/mod_rewrite.html">Module documentation</a></seealso> |
37 | | -<seealso><a href="intro.html">mod_rewrite introduction</a></seealso> |
38 | | -<seealso><a href="remapping.html">Redirection and remapping</a></seealso> |
39 | | -<seealso><a href="access.html">Controlling access</a></seealso> |
40 | | -<seealso><a href="vhosts.html">Virtual hosts</a></seealso> |
41 | | -<!--<seealso><a href="proxy.html">Proxying</a></seealso>--> |
42 | | -<seealso><a href="rewritemap.html">Using RewriteMap</a></seealso> |
43 | | -<seealso><a href="advanced.html">Advanced techniques</a></seealso> |
44 | | -<seealso><a href="avoid.html">When not to use mod_rewrite</a></seealso> |
45 | | - |
46 | | -<section id="dynamic-proxy"> |
47 | | - |
48 | | - <title>Proxying Content with mod_rewrite</title> |
49 | | - |
50 | | - <dl> |
51 | | - <dt>Description:</dt> |
52 | | - |
53 | | - <dd> |
54 | | - <p> |
55 | | - <module>mod_rewrite</module> provides the [P] flag, which allows URLs to be passed, |
56 | | - via <module>mod_proxy</module>, to another server. Two examples are given here. In |
57 | | - one example, a URL is passed directly to another server, and served |
58 | | - as though it were a local URL. In the other example, we proxy |
59 | | - missing content to a back-end server.</p> |
60 | | - </dd> |
61 | | - |
62 | | - <dt>Solution:</dt> |
63 | | - |
64 | | - <dd> |
65 | | - <p>To simply map a URL to another server, we use the [P] flag, as |
66 | | - follows:</p> |
67 | | - |
68 | | -<highlight language="config"> |
69 | | -RewriteEngine on |
70 | | -RewriteBase "/products/" |
71 | | -RewriteRule "^widget/(.*)$" "http://product.example.com/widget/$1" [P] |
72 | | -ProxyPassReverse "/products/widget/" "http://product.example.com/widget/" |
73 | | -</highlight> |
74 | | - |
75 | | - <p>In the second example, we proxy the request only if we can't find |
76 | | - the resource locally. This can be very useful when you're migrating |
77 | | - from one server to another, and you're not sure if all the content |
78 | | - has been migrated yet.</p> |
79 | | - |
80 | | -<highlight language="config"> |
81 | | -RewriteCond "%{REQUEST_FILENAME}" !-f |
82 | | -RewriteCond "%{REQUEST_FILENAME}" !-d |
83 | | -RewriteRule "^/(.*)" "http://old.example.com/$1" [P] |
84 | | -ProxyPassReverse "/" "http://old.example.com/" |
85 | | -</highlight> |
86 | | - </dd> |
87 | | - |
88 | | - <dt>Discussion:</dt> |
89 | | - |
90 | | - <dd><p>In each case, we add a <directive |
91 | | - module="mod_proxy">ProxyPassReverse</directive> directive to ensure |
92 | | - that any redirects issued by the backend are correctly passed on to |
93 | | - the client.</p> |
94 | | - |
95 | | - <p>Consider using either <directive |
96 | | - module="mod_proxy">ProxyPass</directive> or <directive |
97 | | - module="mod_proxy">ProxyPassMatch</directive> whenever possible in |
98 | | - preference to <module>mod_rewrite</module>.</p> |
99 | | - </dd> |
100 | | - </dl> |
101 | | - |
102 | | -</section> |
103 | 38 |
|
104 | 39 | </manualpage> |
0 commit comments