How to redirect www subdomain with Cloudflare

January 23, 2022

You can easily redirect a www subdomain with Cloudflare (like redirecting to

First, we’ll create a dummy record in Cloudflare for the www subdomain, so that Cloudflare can control it.

Create an A record for the www subdomain of your domain, with the IP address This IP address doesn’t actually matter; what matters is that Proxied is turned on. This way, Cloudflare sits in front of your www subdomain, and we can redirect it using Cloudflare.

Next, go to Page Rules for your domain in Cloudflare’s settings.

Create a rule for your www subdomain (for example, if my domain was, I’d do Set the settings to “Forwarding URL” with a 301 redirect to$1 (again, replace with your domain).

Save this page rule. Now, your www subdomain will redirect to the corresponding page on your non-www (“naked”) domain!

Follow my twitter (@benborgers) to see the work-in-progress of coding projects I’m working on!