With the current version of apache, you need to do the following, which has changed compared to the previous versions:
cd /etc/apache2/sites-enabled
Now find the config file for your domain and edit it (the first three lines after <VirtualHost *:80>
is what we need here):
<VirtualHost *:80>
ServerName www.yourdomain.com
ServerAlias yourdomain.com *.yourdomain.com
ServerAdmin webmaster@localhost
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
</VirtualHost>
And now after saving changes to the file, you should reload Apache we server configuration with:
service apache2 reload
and it'll work!
P.S. You may also want not to add *.yourdomain.com
to the end of your ServerAlias
line.