How to setup CNAME properly so "" loads instaed of redirecting to ""

Posted June 10, 2014 7k views
Hi, I've setup a new Droplet and pointed my domain to DO Nameservers. The website loads now only without WWW, page not found with WWW. I've added a CNAME entry with "www @", but this redirects WWW website to non WWW website. We need the WWW version as this is how site is indexed in Google search. How do we make the WWW version load instead or redirecting? What CNAME settings should I add? We are running Apache on Ubuntu, if that helps. Please point us in right direction to resolve this. Thanks.

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
3 answers
It sounds like your DNS records are correct. Could you provide more information about your site? What webserver are you using? Apache, Nginx? If you could pastebin their configurations, we could probably supply you with a better answer.
Having the same issue and I'm not sure the Apache / NGinx is the issue. Take a look at this tutorial. It sounds like it might be the issue.
I stand corrected. I fixed my problem by going into my
$>cd /etc/nginx/sites-enabled
and then doing a:
$>sudo vi
Then add something like this to the top of the config file.
server {
    #listen 80 is default
    return 301 $scheme://$request_uri;

server {
    listen 80;
    root /home/path/to/;
I then restarted ngnix and it worked for me.