How to Configure Cloudflare Pages to Redirect Www to the Root Domain
This guide demonstrates how to resolve issues when https://www.yourdomain.com
doesn’t redirect to https://yourdomain.com
on Cloudflare Pages.
Prerequisites: Complete steps 1-3 from the Cloudflare documentation on redirecting www to domain apex.
Step-by-Step Guide:
-
Create a Bulk Redirect List:
- Log into your Cloudflare account.
- Navigate to Bulk Redirects in the left menu.
- Click Create Bulk Redirect List.
- Select Or, manually add URL redirects and enter:
- Source URL:
www.domain.com
- Target URL:
https://domain.com
- Status:
301
- Source URL:
- Click Edit parameters and enable all available options.
- Save your changes.
-
Create a Bulk Redirect Rule:
- Go to Bulk Redirects in the left menu.
- Click Create Bulk Redirect Rule.
- Under When incoming requests match…, configure:
- Field:
Hostname
- Operation:
contains
- Value:
www.domain.com
- Field:
- In Then, apply matching URL redirects from the following list…, choose your newly created list.
- Save the rule.
-
Verify the Redirect:
- Wait a few minutes for changes to propagate.
- Test using
nslookup
or an online tool like What’s My DNS Redirect Checker. - Ensure URL integrity by checking that
www.domain.com/robots.txt
(or another known file) redirects correctly.
Troubleshooting: If issues persist:
- Double-check all settings in both the Bulk Redirect List and Rule.
- Verify that your domain’s DNS settings are correctly configured in Cloudflare.
- Clear your browser cache or try from a different network to rule out local caching issues.
Additional Resources:
- Cloudflare Pages - Redirecting www to domain apex
- Cloudflare Pages - Custom domains
- Cloudflare Page Rules - URL Forwarding
By following these steps, you should successfully redirect www.domain.com
to your root domain on Cloudflare Pages.