-1

I am trying to create a proxy which will basically do this -

www.google.com.myproxy.com/path?query -> www.google.com/path?query

I am very new to Apache2 and I was able to come up with the following Rewrite rule based on what I understood from their documentation -

RewriteEngine On
RewriteRule ^(.*)\.localhost\.com(.*)$ $1$2 [P]

In this rewrite rule, if I goto www.google.com.myproxy.com I am just seeing the Apaches home page i.e. same content I see if I go to myproxy.com directly. Am I missing something here?

Yash Agarwal
  • 955
  • 1
  • 13
  • 28

1 Answers1

1

I finally figured out the correct Rewrite Rules -

HostnameLookups On
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.myproxy\.com$
RewriteRule ^(.*)$ http://%1$1 [P]

Using this I am able to proxy content using -

www.reddit.com.myproxy.com/r/india 

from

www.reddit.com/r/india

Thanks to following documentation - http://httpd.apache.org/docs/2.2/rewrite/vhosts.html

Yash Agarwal
  • 955
  • 1
  • 13
  • 28