Search code examples
apachewampreverse-proxymod-proxy

Setting up Apache Virtual Hosts and ProxyPass


I am trying to set up Virtual Hosts on my WAMPSERVER 2.0i installation. Currently it looks like that:

http://domain/main
http://domain/sub1
http://domain/sub2

I need to set it up so that 1) accessing http://domain/ would redirect to http://domain/main, but 2) http://domain/sub1 and http://domain/sub2 remain working as they are.

When I'm trying to use ReverseProxy like this

<VirtualHost *:80>
    DocumentRoot "D:/WAMP/www"
    ServerName domain

    ProxyPass / http://domain/main/
    ProxyPassReverse / http://domain/main/

    ErrorLog "logs/error.log"
    CustomLog "logs/access.log" common
</VirtualHost>

it works fine for the first option. However, trying to access http://domain/sub1 or http://domain/sub2 gives me "Error reading from remote server"...

I tried to add something like

ProxyPass /sub1/ http://domain/sub1/
ProxyPassReverse /sub1/ http://domain/sub1/

But without any luck.

Can anyone give any advice about this? Thanks!


Solution

  • Solved in a much easier way. Since I don't care about address line which users can see when they access http://domain/, I used just a simple RedirectMatch.

    RedirectMatch ^/$ /main