所以这就是我想要完成的事情:
如果服务器名称为www.mynewapp.com,则代理通行证或文档根目录应为http://localhost:8080/mynewapp/
如果服务器名称为www.mynewapp.com/app,则代理通行证或文档根目录应为http://localhost:8080/app。
但由于服务器名称不能包含目录(www.mynewapp.com/app),我无法弄清楚。如果我使用Alias '/app'
,即使www.mynewapp.com也会转到/ app版本的文档根目录。
我当前的虚拟主机如下所示:
<VirtualHost *.80>
ServerName www.mynewapp.com
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8888/mynewapp/
ProxyPassReverse / http://localhost:8888/mynewapp/
</VirtualHost>
这适用于第1点。我尝试使用RewriteRules来涵盖这两种情况:
<VirtualHost *.80>
ServerName www.mynewapp.com
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8888/
ProxyPassReverse / http://localhost:8888/
RewriteEngine On
RewriteRule "^/app/(.*)$" "/app/$1"
RewriteRule "^/(.*)$" "/mynewapp/$1"
</VirtualHost>
但是我无法正确使用正则表达式。任何帮助,无论是通过正则表达式还是通过创建2个不同的虚拟主机来解决这两个问题,我们都表示赞赏。
答案 0 :(得分:1)
应该如此简单:
<VirtualHost *.80>
ServerName www.mynewapp.com
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass /app http://localhost:8888/app
ProxyPassReverse /app http://localhost:8888/app
ProxyPass / http://localhost:8888/mynewapp/
ProxyPassReverse / http://localhost:8888/mynewapp/
</VirtualHost>