Zed
Zed

Reputation: 5921

Apache and ProxyPass proxy

I would like to implement a kind of a proxy system, where I can type url like this: http://example.com/www.stackoverflow.com and get contents of www.stackoverflow.com returned. What I tried is this:

ProxyRequests Off
<Proxy *>
Order deny,allow
 Allow from all
</Proxy>

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/external/.*
RewriteRule ^/(.*) http://%{HTTP_HOST}/external/$1 [NC,R=302,L] 
ProxyPassMatch  /external/([A-Za-z]*)/(.*)  wwww.stackoverflow.com/$1/$2
ProxyPassMatch  /external/(.*)  http://$1/

This works fine, but works only for stackoverflow.com because it is hardcoded. Is there some kind of rule so that dynamic URL can work, so I can use http://example.com/yahoo.com ? And yes, if try to hardcode yahoo.com or google.com, instead of rewrite url get automatically redirected to yahoo.com or google.com, what's up with that ?

Upvotes: 0

Views: 113

Answers (1)

arco444
arco444

Reputation: 22881

You can use the [P] flag of RewriteRule:

RewriteEngine On
RewriteRule ^/(.*) http://$1 [P]

More info here

Upvotes: 1

Related Questions