2010-09-27 168 views
0

我想在我的WAMPSERVER 2.0i安装上设置虚拟主机。目前,它看起来像这样:设置Apache虚拟主机和ProxyPass

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

我需要设置它,以便1)访问http://domain/会重定向到http://domain/main,但2)http://domain/sub1http://domain/sub2保持原样工作。

当我尝试使用反向代理这样

<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> 

正常工作的第一选择。但是,试图访问http://domain/sub1http://domain/sub2给我“从远程服务器读取错误” ......

我尝试添加像

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

,但没有任何运气。

任何人都可以提供任何意见吗?谢谢!

回答

0

以更简单的方式解决。由于我不关心用户在访问http://domain/时可以看到的地址栏,我只用了一个简单的RedirectMatch

RedirectMatch ^/$ /main 
0

听起来好像您可能需要为sub1和sub2指定别名(和位置/目录)指令。

更一般地说,因为您似乎在运行来自同一个域的所有内容,所以可能应该使用mod_rewrite而不是代理。

+0

是的,你说得对。代理并不是最好的主意。不知道为什么我从一开始就坚持下去...... – Jull 2010-09-27 23:06:17