From: Rich Bowen Date: Thu, 30 Apr 2026 20:36:04 +0000 (+0000) Subject: rewrite guide: merge proxy.xml content into avoid.xml, replace proxy.xml with depreca... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5628349fc675c494b8b2fa2831c87f12cadade57;p=thirdparty%2Fapache%2Fhttpd.git rewrite guide: merge proxy.xml content into avoid.xml, replace proxy.xml with deprecation stub (BZ 58892, step 5) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1933622 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/avoid.xml b/docs/manual/rewrite/avoid.xml index 3e42770c3b..c9d0cefdb6 100644 --- a/docs/manual/rewrite/avoid.xml +++ b/docs/manual/rewrite/avoid.xml @@ -189,6 +189,25 @@ other RewriteRules in effect in the same scope, as a ProxyPass, and so may preempt what you're trying to accomplish.

+

One case where RewriteRule +is genuinely useful for proxying is when you want to proxy requests only +for content that doesn't exist locally — for example, during a migration +from one server to another:

+ + +RewriteCond "%{REQUEST_FILENAME}" !-f +RewriteCond "%{REQUEST_FILENAME}" !-d +RewriteRule "^/(.*)" "http://old.example.com/$1" [P] +ProxyPassReverse "/" "http://old.example.com/" + + +

In this example, requests for resources that haven't been migrated +yet are transparently proxied to the old server. As content is migrated, +the local files take precedence. Remember to always include a +ProxyPassReverse directive to +ensure that any redirects issued by the backend are correctly passed on +to the client.

+
Environment Variable Testing diff --git a/docs/manual/rewrite/proxy.xml b/docs/manual/rewrite/proxy.xml index 7d643e65fd..5e307322aa 100644 --- a/docs/manual/rewrite/proxy.xml +++ b/docs/manual/rewrite/proxy.xml @@ -27,78 +27,13 @@ -

This document supplements the mod_rewrite -reference documentation. It describes -how to use the RewriteRule's [P] flag to proxy content to another server. -A number of recipes are provided that describe common scenarios.

+This document has been deprecated. Its content has +been merged into the +When not to use mod_rewrite document, +since simple proxying is better accomplished using +ProxyPass. This page will be +removed in a future version of this documentation.
-Module documentation -mod_rewrite introduction -Redirection and remapping -Controlling access -Virtual hosts - -Using RewriteMap -Advanced techniques -When not to use mod_rewrite - -
- - Proxying Content with mod_rewrite - -
-
Description:
- -
-

- mod_rewrite provides the [P] flag, which allows URLs to be passed, - via mod_proxy, to another server. Two examples are given here. In - one example, a URL is passed directly to another server, and served - as though it were a local URL. In the other example, we proxy - missing content to a back-end server.

-
- -
Solution:
- -
-

To simply map a URL to another server, we use the [P] flag, as - follows:

- - -RewriteEngine on -RewriteBase "/products/" -RewriteRule "^widget/(.*)$" "http://product.example.com/widget/$1" [P] -ProxyPassReverse "/products/widget/" "http://product.example.com/widget/" - - -

In the second example, we proxy the request only if we can't find - the resource locally. This can be very useful when you're migrating - from one server to another, and you're not sure if all the content - has been migrated yet.

- - -RewriteCond "%{REQUEST_FILENAME}" !-f -RewriteCond "%{REQUEST_FILENAME}" !-d -RewriteRule "^/(.*)" "http://old.example.com/$1" [P] -ProxyPassReverse "/" "http://old.example.com/" - -
- -
Discussion:
- -

In each case, we add a ProxyPassReverse directive to ensure - that any redirects issued by the backend are correctly passed on to - the client.

- -

Consider using either ProxyPass or ProxyPassMatch whenever possible in - preference to mod_rewrite.

-
-
- -