Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have Ubuntu running with Apache2, my website shows in browser when www.example.com but doesn't show when example.com, my website is in /home/username/public_html/example.com/public.

I used following, which doesnt work

sudo bash -c "cat >> /etc/apache2/sites-available/example.com <<EOF

<VirtualHost *:80>

  ServerName  www.example.com
  ServerAlias example.com
  DocumentRoot /home/username/public_html/example.com/public

</VirtualHost>

EOF"
share|improve this question

1 Answer 1

You should look into /etc/hosts. You need to include both:

127.0.0.1 www.example.com 
127.0.0.1 example.com

Let me know if that works.

share|improve this answer
    
Eh, no, he doesn't have problem with the hosts, but with the virtual host. –  Braiam Dec 16 '13 at 2:22

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.