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 the /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 to example.loc
, it works properly, but if I go to www.example.loc
, it does not work, saying that it is "impossible to find www.example.loc
"!
Have I done something wrong in the configuration?