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


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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I stand corrected. I fixed my problem by going into my <pre> $>cd /etc/nginx/sites-enabled </pre> and then doing a: <pre> $>sudo vi </pre> Then add something like this to the top of the config file. <pre> server { #listen 80 is default server_name; return 301 $scheme://$request_uri; }

server { listen 80; server_name; root /home/path/to/; … </pre>

I then restarted ngnix and it worked for me.

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.

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.