elloo,
我有两个虚拟主机子域指向不同的目录但是当我在浏览器中加载两个子域时,我得到它们都指向同一目录。这是我的vhost.conf
<VirtualHost *:80>
ServerAdmin admin@domain.com
ServerName subdomain1.domain.com
ServerAlias *.domain.com
#Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /subomain1/path/to/directory/trunk
#Logfiles
ErrorLog /subomain1/path/to/directory/trunk/error.log
CustomLog /subomain1/path/to/directory/trunk//access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin admin@domain.com
ServerName subdomain1.domain.com
ServerAlias *.subdomain.com
DirectoryIndex index.php
DocumentRoot /subomain1/path/to/directory/trunk
SSLEngine On
SSLCertificateFile /ssl/certs/subdomain1.crt
SSLCertificateKeyFile /ssl/private/subdomain1.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin@domain.com
ServerName subdomain2.domain.com
ServerAlias *.domain.com
#Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /subomain2/path/to/directory/trunk
#Logfiles
ErrorLog /subomain2/path/to/directory/trunk/error.log
CustomLog /subomain2/path/to/directory/trunk//access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin admin@domain.com
ServerName subdomain2.domain.com
ServerAlias *.subdomain.com
DirectoryIndex index.php
DocumentRoot /subomain2/path/to/directory/trunk
SSLEngine On
SSLCertificateFile /ssl/certs/subdomain2.crt
SSLCertificateKeyFile /ssl/private/subdomain2.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
我试过google但是没有一个答案似乎有帮助。
我正在使用ubuntu服务器
非常感谢提前
答案 0 :(得分:1)
不知道你是否解决了这个问题,但我遇到了同样的问题,结果发现我忘了改变httpd.conf这样的文件:
打开“httpd.conf”并取消注释#461(约)行,其中包含“Include /private/etc/apache//dxtra/httpd-vhosts.conf”,然后保存。
取自本教程,是无价之宝: http://kevchapman.co.uk/development/setting-up-apache-on-snow-leopard/
答案 1 :(得分:0)
我认为是因为你正在使用它 ServerAlias * .domain.com 在两个虚拟主机上
因为ServerAlias指令表明列出的名称是人们可以用来查看同一网站的其他名称:
ServerAlias * .subdomain.com
然后subdomain1.domain.com虚拟主机将为subdomain.com域中所有主机的请求提供服务。
这可能有助于http://httpd.apache.org/docs/2.0/vhosts/name-based.html