Mod_rewrite Proxy – maintain host headers

apache-2.2mod-rewrite

I am using mod_rewrite to proxy a sub-directory like this:

RewriteRule  ^somedir/(.*)$  http://proxy.example/somedir/$1  [P,L]

That means that requests to http://local.example/somedir are proxied to http://proxy.example/somedir

I am being told by the people at remote location (e.g. proxy.example) that the host headers being read by their systems see "proxy.example" as the host, but that they require us to maintain "local.example" as the host header.

How can this be done? I am hoping to keep it all in .htaccess and not have to move to ProxyPass.

Best Answer

ProxyPreserveHost may work for you in this situation. See http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost

Related Topic