Redirecting Naked Domain to www
To redirect a naked domain (example.com) to a www subdomain (www.example.com) using Cloudflare, follow these steps:
-
Log in to Cloudflare: Go to the Cloudflare dashboard and log in to your account.
-
You MUST make sure that your domain is added to Cloudflare.
-
The weirdest part: You need a DNS record for the naked domain. My recommendation is to route to the exact same location as your WWW (or whatever subdomain). This is because Cloudflare cannot process rules for a domain if it is not proxied.
-
The root domain DNS setting MUST have proxying activated. Even if you don’t have proxying for your WWW, but you do need proxying active for your ROOT.
-
Visit RULES inside your domain.
https://developers.cloudflare.com/rules/url-forwarding/single-redirects/create-dashboard/
- Make sure you notice there are 2 wildcards. The bottom line should use the {2} for the path since it represents the path of the URL. The first capture should be disregarded.