I have a website that I want to be able to reach using
http://mydomain.com as well as
Recently I configured my servers
I have installed apache2 in default from ubuntu 12.04 repositories and configured the following configuration file under
<VirtualHost *:80> ServerName mydomain.de ServerAlias www.mydomain.de DocumentRoot /home/mydomain/public </VirtualHost> <Directory /home/mydomain/public> AllowOverride All </Directory>
Now If I request
http://www.mydomain.com everything works, but if I request
http://www.mydomain.com 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...