Question

Websites do not load with www

I am running multiple Wordpress sites on my server. I can load my sites with just **http://**sitename.com but they will not load when I use **www.**sitename.com. I added a DNS CNAME record with www and @ to each website but it redirects to an unavailable page instead of my correct website. It looks like it’s redirecting my websites to my DigitalOcean IP Address. How do I fix this?


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.

Hi,

There are typically two configurations required to do what you want to do:

  1. the www DNS needs to resolve to the same IP as the websites, typically your Droplet IP or another domain that resolves to your Droplet IP
  2. your web server configuration (apache or nginx typically) needs to perform a redirect when a site is requested for

From your description of the problem, it sounds like your DNS is setup correctly but the second part, the part that will redirect the www request to the right site, is not.

This past answer has some of the webserver configuration info for Apache and Nginx (right after):

https://www.digitalocean.com/community/questions/how-can-i-redirect-www-mysite-com-to-mysite-com-using-digitalocean-dns?answer=13333

Both of these examples are for a virtual host that listens for the www domain and then redirects it to the non-www version of the site domain. A “301” redirect is a “permanent” redirect (for search engine purposes).

If you’re still stuck and you are using Apache, here is a DigitalOcean tutorial that uses an A record instead of a CNAME - reviewing these steps might help with your issue.

https://www.digitalocean.com/community/tutorials/how-to-redirect-www-to-non-www-with-apache-on-ubuntu-14-04

Here’s another tutorial on redirects that includes some nginx info too:

https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx

If you are stuck, please reply with a little more information like which web server are you using (apache or nginx, for example).

Hope this helps and good luck!