Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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
share|improve this question
Did you define it somewhere else? Post the output of httpd -S. –  Michael Hampton Oct 3 '13 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 '13 at 1:23

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
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 '13 at 1:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.