Virtual host configuration question

Discussion in 'Apache' started by wwarren, Jul 29, 2013.

  1. #1
    I have a weird situation maybe someone can help with. I've set up three virtual hosts in httpd.conf for a personal blog, a music server, and a company website. Let's call them blog.com, music.com, and company.com. From outside the LAN that the server is on, everything works. From inside the LAN, the blog and music server work, but trying to access company.com results in blog.com loading. Why? Unless I can fix it, doing any development work on it is going to have to be done remotely.

    <Directory /var/www/wordpress>
    Options FollowSymLinks
    AllowOverride FileInfo
    </Directory>

    <VirtualHost *:80>
    DocumentRoot /var/www
    ServerName www.blog.com
    </Virtualhost>

    <VirtualHost *:80>
    DocumentRoot /var/www/mtdaapd
    ServerName music.com
    </Virtualhost>

    <VirtualHost *:80>
    DocumentRoot /var/www/wordpress
    ServerName blog.blog.com
    </Virtualhost>

    <VirtualHost *:80>
    DocumentRoot /var/www/wg
    ServerName www.company.com
    </VirtualHost>
     
    wwarren, Jul 29, 2013 IP
  2. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #2
    When there is no virtual host matching the hostname(URL), the first virtual host will be used.
    www.company.com is not same with company.com

    You should add ServerAlias to VirtualHost configuration
    <VirtualHost *:80>
        DocumentRoot /var/www/wg
        ServerName www.company.com
        ServerAlias company.com
    </VirtualHost>
    Code (markup):
     
    RoseHosting, Jul 30, 2013 IP