Does not work without the WWW

Posted April 11, 2014 1.9k views
Hello everyone. I'm kind of newbie in both VPS and Ubuntu LAMP server configuration. Just followed some community tutorials on how to instal ubuntu and then apache, php, mysql, etc. My goal is to have some domains hosted in the same droplet so I followed the virtual hosts tutorials. The problem is that my domain is working with the WWW but it's not working without it: working not working After reading a lot, I haven't found anything similar to this. Can someone help me? Thank you so much!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
5 answers
In the DNS settings create an 'A' record with hostname: '@' and IP Address: . 'WWW' should be set as 'CNAME' record of '@'
Thank you edwingonzales1123!
I already have that (followed the tutorials) but the problem is exactly the oposite. It works fine if I put the "WWW" but it doesn't work if I just type "", it shows the directory contents from the /var/www folder.

Please pastebin your virtualhost config.
Hello Kamal. Thank you for your help!
I think I got it to work now.

I had 2 virtualhosts ... the default one and the one for
In the default one, the document root was pointing to /var/www and I changed it to /var/www/ and it's working now. Don't know if it is the best way but I'll move on now :) need to prototype this app asap hehe

Thank you again for your help (and edwingonzales1123 too).
That is the proper way to fix it :) Glad to hear it's working properly now!