Using mod_rewrite for Proxying

This document supplements the mod_rewritereference 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.

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:

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.

Notice: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 mailing lists.