I know it is a question asked several times, but I've read them all and not solved the problem. I have configured the virtualhost apache like this:
sudo nano /etc/apache2/sites-available/example.loc
<VirtualHost *:80> ServerName example.loc ServerAlias www.example.loc DocumentRoot /var/www/example/web <Directory /var/www/example/web> AllowOverride All Order allow,deny Allow from All </Directory> ErrorLog /var/log/apache2/project_error.log CustomLog /var/log/apache2/project_access.log combined
I put this in /etc/hosts file:
127.0.0.1 localhost 127.0.0.1 example.loc
and then I loaded the site in this way:
sudo a2ensite example.loc
and restarted apache.
If I go on example.loc working properly, but if I go on www.example.loc does not work, saying that it is impossible to find www.example.loc!
I have done something wrong in the configuration?