1

I'm trying to route a top level domain through Apache Virtual Hosts, but I can't seem to get it to work.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName mydomain.net
    ServerAlias www.mydomain.net
    DocumentRoot /var/www/tgc
</VirtualHost>

www.mydomain.net works perfectly. But mydomain.net continues to route to /var/www. I've tried suggestions here and many different combinations, but nothing seems to work.

apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server mydomain.net (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost mydomain.net (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost mydomain.net (/etc/apache2/sites-enabled/000-default:54)
Syntax OK
2
  • Did you define it somewhere else? Post the output of httpd -S. Oct 3, 2013 at 0:43
  • @MichaelHampton yeah that doesn't look right... but I don't know how to fix it. Edited to question.
    – mawburn
    Oct 3, 2013 at 1:23

1 Answer 1

3

You defined two virtual hosts for your domain, and so only one of them is used. Fix this by removing one of them.

1
  • Yup. I had to change the DocumentRoot on the main VirtualHost to the correct path. This server is hosting many different subdomains and I did not think of that.... Thank you.
    – mawburn
    Oct 3, 2013 at 1:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .