从虚拟主机中排除正则expression式

我有一个虚拟主机在Apacheredirect到另一个Web服务器的请求。

<VirtualHost *:80> DocumentRoot /var/www ServerName another.host ProxyPass / http://another.host2:8081/ ProxyPassReverse / http://another.host2:8081/ </VirtualHost> 

我需要排除一个URL模式被这个虚拟主机捕获。 基本上我不希望与url: http : //another.host : 8081/ ~ username被转发到其他服务器的请求。

可以这样做吗?

是和不是。

不,你不能排除匹配VirtualHost的东西; 与主机名称匹配的任何东西都将始终附加到该VirtualHost。

是的,你可以通过让你的ProxyPass只发生在你不想在本地服务的地方,来获得你想要的行为。

尝试这样的事情:

 <VirtualHost *:80> DocumentRoot /var/www ServerName another.host <Location /> Order deny,allow Allow from all </Location> <LocationMatch "^/[^~]"> ProxyPass / http://another.host2:8081/ ProxyPassReverse / http://another.host2:8081/ </LocationMatch> </VirtualHost>