Apache virutalhost subdomains point to same directory
elloo,
i have two virtualhost subdomains point to different directories however when i load both subdomains in the browser, i get them both pointing to same directory. here is my 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/pa开发者_高级运维th/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>
i have tried google however none of the answers seems to help.
i'm using ubuntu server
many thanks in advance
don't know if you ever solved this, but i was having the same problem and it turned out i forgot to change the httpd.conf file like this:
Open the “httpd.conf” and uncomment line #461 (approx) which reads “Include /private/etc/apache2/extra/httpd-vhosts.conf”, then save.
taken from this tutorial which is priceless: http://kevchapman.co.uk/development/setting-up-apache-on-snow-leopard/
I think its because youre using ServerAlias *.domain.com on both virtual hosts
since the ServerAlias directive indicates that the listed names are other names which people can use to see that same web site:
ServerAlias *.subdomain.com
then requests for all hosts in the subdomain.com domain will be served by the subdomain1.domain.com virtual host.
this might help http://httpd.apache.org/docs/2.0/vhosts/name-based.html
精彩评论