January 23, 2022
You can easily redirect a www subdomain with Cloudflare (like redirecting www.example.com
to example.com
).
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 192.0.2.1
. 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 example.com
, Iād do www.example.com
). Set the settings to āForwarding URLā with a 301 redirect to https://example.com/$1
(again, replace example.com
with your domain).
Save this page rule. Now, your www
subdomain will redirect to the corresponding page on your non-www (ānakedā) domain!