Question

How to 301 redirect? (cloudflare)

I’ve my website and dns on digitalocean. I want to 301 redirect non-www urls to www urls. Currently I found answers for apache server, but not for cloudflare. Does anyone know how to do it? I don’t want to change nameservers to Cloudflare website.

Subscribe
Share

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

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.

Hi @NitinAngler,

I’ll recommend you to not add your 301 redirects on Cloudflare but on your Application.

@alexdo has already provided answers on how to do Nginx and Apache redirect but if you want to do redirect on your App Platform check the following questions:

https://www.digitalocean.com/community/questions/app-platform-how-can-i-redirect-non-www-to-www

https://www.digitalocean.com/community/questions/redirect-non-www-to-www-using-app-platform

Hello there,

If I understand this correctly you want the redirection to happen on DigitalOcean’s end and not Cloudflare since you do not want to change your nameservers to CF?

Are you using Apache/Nginx on your server? You can check this tutorial for more information:

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

Hope that this helps!