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.
Apache Web Server

Avatar of undefined
Last Comment
magicmike

8/22/2022 - Mon
Jan Bacher

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.
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.
Jan Bacher

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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
magicmike

ASKER
Yup...  syntax is ok. I did reload.  Nothing.

It's Ubuntu 14
Jan Bacher

Can you post the conf file in which these are configured?
magicmike

ASKER
<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>
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jan Bacher

Have you tried putting these each on their own line?

            ServerAlias domain.com test.d2.com
magicmike

ASKER
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
Jan Bacher

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
magicmike

ASKER
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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck