How to create a reverse proxy to host specified in url

apache-2.2mod-proxyreverse-proxy

I need to configure proxy with apache to proxy requests like

http://example.com/proxy/www.anothersite.com/[some-params]

to

http://www.anothersite.com/[some-params]

I tried to do this like that:

<LocationMatch ^/proxy/(.*)$>
    ProxyPassMatch http://$1
</LocationMatch>

But how can I make all redirects that sends to me remote host go via proxy? For example, if I go to url:

http://example.com/proxy/another-site.com

and another-site.com send me redirect to yet-another-site.com, it shall forward my browser to

http://example.com/proxy/yet-another-site.com

Best Answer

You can use Apache ProxyPassReverse directive for this. You can find its documentation in Apache documentation