Question

Redirect www to naked domain

I have pointed the domain name servers to DO and I am trying to get the www subdomain to point to the naked domain. I have tried CNAME and A host but not luck. Is there a simple/straightforward way of having the www subdomain redirect or point to the naked domain?


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.

Hello @massiveseagreenray

If you’re using Nginx, take advantage of our NGINX tool and specify the redirection there.

https://www.digitalocean.com/community/tools/nginx

For Apache, you can do a basic 301 redirect rule in the .htaccess file or in the virtual host for the domain name.

Regards

Hi @massiveseagreenray,

Through DNS you can point the www.domain.com record to the same one as domain.com.

After that you want when someone loads www.domain.com to redirect to domain.com, correct? If that’s the case, this redirect happens on a server level. You’ll need to put the redirect in Nginx or Apache2 depending on what you are using. The redirects are rarely done via DNS but from the server your app is being managed.