Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a website that I want to be able to reach using as well as

Recently I configured my servers hostname to

I have installed apache2 in default from ubuntu 12.04 repositories and configured the following configuration file under /etc/apache2/sites-enabled/

<VirtualHost *:80>
        DocumentRoot /home/mydomain/public
<Directory /home/mydomain/public>
        AllowOverride All

Now If I request everything works, but if I request I get the default "it works" apache welcome page.

If I prefix my config file in a way that it gets listed even before the 000-default vhost, so it looks like this:

ls -lha /etc/apache2/sites-enabled/
total 8.0K
drwxr-xr-x 2 root root 4.0K Jul  6 18:46 .
drwxr-xr-x 7 root root 4.0K Oct  5  2012 ..
lrwxrwxrwx 1 root root   33 Jul  6 18:45 000-0mydomain -> /home/mydomain/apache2.conf
lrwxrwxrwx 1 root root   26 Jul  6 18:29 000-default -> ../sites-available/default

it does work.

However I do not know whether this is a good idea or why this occurs in the first place. It also works when the server hostname does not correspond to the domain name!

I think apache is somehow unable to distinguish between requests without host header and requests whith the host header that is the same as the hostname...

So what can I do about this? How can I properly do this?

I think adjusting the name so my vhost ocmes eben before the default which is not named 000-default just to annoy people is not a good idea...

share|improve this question
Do you still need the default file enabled at all? – Shane Madden Jul 6 '13 at 16:40
@Shane Madden no, i dont... not really... but i dont know about the future. i would like to set this up as clean and compatible as possible – The Shurrican Jul 6 '13 at 16:54

When you type hostname -f, is that your domain as well? I think the default vhost is responding to the machine domain name. My advice would be to set a different host name for the machine, because the name you use to administer it should be different from the website that runs on it. Otherwise, you won't be able to do things like give the website a temporary different address and display a maintenance message.

If you don't want to do that, you can configure a dummy ServerName in 000-default.

share|improve this answer
yes, hostname -f is also that domain. i configured the machines hostname to the same domain for reasons when sending email. those problems i had have been completely solved and this new one arose. also modifying the default vhost is not really what i want. i prefer having all my stuff in one config file that i symlink and have in a versionized folder. – The Shurrican Jul 6 '13 at 16:13
I mean, just having the 'it works' vhost's servername be That should fix it. – Halfgaar Jul 6 '13 at 20:16

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.