开发者

Setting up Apache Virtual Hosts and ProxyPass

开发者 https://www.devze.com 2023-01-17 15:55 出处:网络
I am trying to set up Virtual Hosts on my WAMPSERVER 2.0i installation. Currently it looks like that:

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. Howev开发者_StackOverflow社区er, 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!


It sounds like you may need to specify Alias (and Location/Directory) directives for sub1 and sub2.

More generally, since you seem to be running everything from the same domain, it's probably mod_rewrite you should use, not proxy.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号