Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 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:

127.0.0.1   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

 
discard

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.