Virtual hosts not recognizing domains without prefixes

Discussion in 'Apache' started by murkis, Jun 3, 2009.

  1. #1
    Hello, i have a problem with virtual hosts. I am running debian 5 with apache 2. In /etc/apache2/sites-available i have a default configuration and one for a virtual host. Both enabled. The default looks like this:

    
    NameVirtualHost *:80
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /some/path
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /some/path/>
                    Options -Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
    
            ErrorLog /var/log/apache2/error.log
            LogLevel warn
            CustomLog /var/log/apache2/access.log combined
    </VirtualHost>
    
    Code (markup):
    And there's a virtualhost, configured like this:

    
    #
    #  domain.com (/path/)
    #
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            ServerName  www.domain.com
            ServerAlias domain.com *.domain.com
    
            DocumentRoot /path/
    
            <Directory /path/>
                    AllowOverride All
            </Directory>
    
            # CGI Directory
            ScriptAlias /cgi-bin/ /path/cgi-bin/
            <Location /cgi-bin>
                    Options +ExecCGI
            </Location>
    
            LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
            CustomLog /var/log/apache2/access.domain.log combined
    
    </VirtualHost>
    
    Code (markup):
    The /etc/hosts file contains:

    
    127.0.0.1 localhost.localdomain localhost
    127.0.0.1 subdomain.domain.com
    # Auto-generated hostname. Please do not remove this comment.
    ?.?.?.? domain.com domain domain
    
    Code (markup):
    Question marks simply hide my ip


    It works if i navigate to *.domain.com, but if i navigate to domain.com precisely (without any prefix) - it shows me the default website from the default config. I've defined "domain.com" in aliases so why doesn't it work ?
     
    murkis, Jun 3, 2009 IP
  2. vasyl

    vasyl Peon

    Messages:
    138
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    what httpd -S -w says?
     
    vasyl, Jun 3, 2009 IP
  3. murkis

    murkis Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There is no such command, something is probably not installed.
     
    murkis, Jun 4, 2009 IP