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.

alexdo
Site Moderator
Site Moderator badge
August 29, 2022

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

KFSys
Site Moderator
Site Moderator badge
August 28, 2022

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.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up