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

June 10, 2014 2.2k 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.
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.
by Assaf Gordon
Here's some documentation on how to set up and test DNS subdomains with DigitalOcean's DNS panel.
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.
Have another answer? Share your knowledge.