Custom Cloudflare domain and www redirect
How to redirect www to your custom Cloudflare domain.
Why doesn’t www work for my domain?
Cloudflare can serve as an excellent static site host, we use it for this blog. It’s also simple
to register a custom domain and have it auto-setup, but unfortunately the www subdomain doesn’t automatically redirect
as expected. By default
https://mysite.com will work, but
www.mysite.com won’t. Here’s how we fix it.
- In your Cloudflare dashboard, go to Websites > your website > DNS. Add a new CNAME entry with the name
mysite.comas target, and make sure you turn on the proxy.
- Go to Rules > Page Rules and set up a new redirect rule. Set the URL to
www.mysite.com/*, pick the
Forwarding URLsetting, and the
301status code. Set the destination URL to
And we’re done, www should now redirect to you domain as expected.