Redirecting www to domain apex
To do this, create a DNS record for the
www subdomain. It must either be an
A record with the
192.0.2.1 value or an
AAAA record with the
100:: value. The new DNS record must also have Cloudflare’s proxy enabled (orange-clouded) so that it can enact the Page Rule behavior that you will create next.
Next, make the Page Rule which will handle the redirect. For this, you will make it so all paths get redirected. This is done with a 301 (Permanent Redirect). Matching all paths allows for someone visiting
www.example.com/blog/category/example to be redirected to
To do this:
- Go to Rules .
- Select Create Page Rule.
- Set the target to
/*is what matches all paths.
- Select Forwarding URL from the dropdown and select the 301 - Permanent Redirect option from the status code dropdown.
- Finally, for the Forwarding URL location, set it to
$1will be replaced by the wildcard match in target (the
Finally, select Save and wait a few seconds for your rule to propagate.