Virtual Host settings only serve first listed Virtual Host

Discussion in 'Apache' started by Kevin Chappell, Jan 13, 2011.

  1. #1
    A very strange problem indeed. I have configured virtual hosts many times before and according to my other setups and the Apache 2.2 documentation I am doing everything correctly.

    The environment is Apache 2.2 on CentOs. I put the following code at the end of my httpd.conf file:

    NameVirtualHost *:80
    
    <VirtualHost *:80>
        ServerAdmin kevin@mydomain.com
        ServerName subdomain.subdomain.domain.com
        ServerAlias subdomain
        DocumentRoot /var/www/domain1/html
        ScriptAlias /cgi-bin/ /var/www/domain1/html/cgi-bin/    
        ErrorLog /var/www/domain1/error/log
    </VirtualHost>
    <VirtualHost *:80>
        ServerAdmin kevin@mydomain.com
        ServerName subdomain2.subdomain.domain.com
        ServerAlias subdomain2
        DocumentRoot /var/www/domain2/html
        ScriptAlias /cgi-bin/ /var/www/domain2/html/cgi-bin/
        ErrorLog /var/www/domain2/error/log
    </VirtualHost>
    <VirtualHost *:80>
        ServerAdmin kevin@mydomain.com
        ServerName subdomain3.subdomain.domain.com
        ServerAlias subdomain3
        DocumentRoot /var/www/domain3/html
        ErrorLog /var/www/domain3/error/log
    </VirtualHost>
    Code (markup):
    I have also tried:
    <VirtualHost *:80>
    <VirtualHost *>
    <VirtualHost [The_Server_IP]>

    but the end result is the same.

    How can name-based virtual host work for only the first listed vhost?
     
    Kevin Chappell, Jan 13, 2011 IP