我有一个Java应用程序响应多个域,并为每个域使用特定的apache虚拟主机。这是因为Apache比tomcat更快,可以提供静态资源。apache虚拟主机和“动态”域
需要在运行时执行此操作,而无需重新启动apache配置。 要执行这个动作我使用VirtualDocumentRoot指令,如下所述:
AddType text/html .html .shtml
AddOutputFilter INCLUDES .html .shtml
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
ServerName domain.com
ServerAlias *
# Define virtual host directory, using entire domain
VirtualDocumentRoot /path/to/whosts/%0
# Define directory access
<Directory "/path/to/whosts/">
Options -Indexes MultiViews +Includes
Order allow,deny
Allow from all
</Directory>
# Define Java Proxies
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
# Allow Libs (static resources) to access apache directly
ProxyPass /libs !
ProxyPass/ajp://localhost:8009/
ProxyPassReverse/ajp://localhost:8009/
</VirtualHost>
这并不能很好的工作,因为如果我尝试访问www.domain.com,要比访问domain.com不同。
您认为注册从www.domain.comto domain.com的符号链接是个好主意吗?
存在另一种方式来做到这一点?我在apache管理方面真的很差...
非常感谢!
Ciao,Davide。