Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 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

ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined

I put this in /etc/hosts file:   localhost   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?

share|improve this question
up vote 3 down vote accepted

That is becuase www.example.loc is a different FQDN than example.loc is, and you haven't specified the former in your hosts file.

Just make the line of your hosts file look like this:   example.loc www.example.loc
share|improve this answer
Thank you! So it works! But there is a problem with the use of the sessions. In fact, if you are logged on example.loc, if I go to www.example.loc are not logged in! it is as if I went on two different sites! – Lughino Sep 5 '13 at 19:16
Well that's a software development problem, not a systems administration problem. – EEAA Sep 5 '13 at 19: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.