Search code examples
apachemod-rewritemod-proxy

Use apache as a foward proxy and redirect all reques to a static page


I trying to set up Apache as proxy which will eventually rewrite requests for JavaScript files to a different codes base. I have Apache set up and acting as a proxy but no matter what I do it will not use the rewrite rule config is shown below.

Currently this is all ruining on my local machine.

<VirtualHost *:8000>
RewriteEngine on 
RewriteRule "(.*)" "http://127.0.0.1/test.html" [P]
DocumentRoot "c:/wamp/www/ipvproxy"
ServerName ipvproxy
ProxyRequests On
ProxyVia On
<Proxy *>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Proxy> 

Working Config

<VirtualHost aaa.bbb.ccc.ddd:8000>
   DocumentRoot "c:/wamp/www/"
   CustomLog "c:/wamp/logs/vhost.log" common
   ErrorLog "c:/wamp/logs/vhost_error.log"
   ProxyRequests On
   <Proxy *>
      Order deny,allow
      Deny from all
      Allow from all
   </Proxy>
   RewriteEngine on
   RewriteLog "c:/wamp/logs/rewrite2.log"
   RewriteLogLevel 9
   RewriteRule .* http://127.0.0.1/test.html
</VirtualHost>

Solution

  • It turns out the issue lay with the wampserver version I was using. Running Wampserver 64 bit on Windown 7 64 bit has issues with mod_rewrite, changed to wampserver 32 bit and it all started to work.