Link to home
Start Free TrialLog in
Avatar of magicmike
magicmike

asked on

Configuring Apache2 with multiple domain names going to one virtualhost

I'm attempting to point multiple domains to one virtualhost.

For Example:

ServerName www.domain.com
ServerAlias domain.com test.d2.com

When going to test.d2.com, it pulls up the default website and not www.domain.com.  The config file link for www.domain.com is enabled/active.  I'm unable to point www.domain.com to the new server until I know this is working.  Please let me know how I can troubleshoot this issue.

BTW, this is a fresh install.
Avatar of Jan Bacher
Jan Bacher
Flag of United States of America image

One alias per line

ServerAlias www.domain.com
ServerAlias another.domain.com
etc.

DNS must appropriately reflect the correct IP for all Names and Aliases.
Avatar of magicmike
magicmike

ASKER

Yeah, I've attempted that already.  I was able to bring down one old domain for testing and it appears that even it is going to the default instead of the assigned root.
Did you reload apache?

Because, if you're hitting the landing page, it sounds as if DNS is configured but the new configuration has not been loaded.

   apachectl -t

If all good, Centos 6 or Ubuntu

  service httpd reload
Yup...  syntax is ok. I did reload.  Nothing.

It's Ubuntu 14
Can you post the conf file in which these are configured?
<VirtualHost *>
        ServerAdmin user@domain.com
        ServerName  www.domain.com
        ServerAlias domain.com test.d2.com

        # Indexes + Directory Root.
        DirectoryIndex index.html
        DocumentRoot /var/www/domain.com/htdocs

        # CGI Directory
        ScriptAlias /cgi-bin /var/www/domain.com/cgi-bin
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>

        # Logfiles
        ErrorLog  /var/www/domain.com/logs/error.log
        CustomLog /var/www/domain.com/logs/access.log combined
</VirtualHost>
Have you tried putting these each on their own line?

            ServerAlias domain.com test.d2.com
yeah, i did that.  I also have just a normal site with no special alias.  exactly the same, no test.d2.com and it's also bringing up the default.
ASKER CERTIFIED SOLUTION
Avatar of Jan Bacher
Jan Bacher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
We're pretty much in sync for the things I tried before getting on here.  Looks like we finally have the right combination, though.  I tried *:80 earlier and nothing, but it worked this time with everything else in line.

Thanks for helping work this out.