Learn how to redirect a www subdomain to your apex domain (example.com).
This setup assumes that you already have a custom domain attached to your Pages project.
To redirect your www subdomain to your domain apex:
-
In the Cloudflare dashboard, go to the Bulk Redirects page.
Go to Bulk redirects ↗ -
Create a bulk redirect list modeled after the following (but replacing the values as appropriate):
| Source URL | Target URL | Status | Parameters |
|---|---|---|---|
www.example.com |
https://example.com |
301 |
|
- Create a bulk redirect rule using the list you just created.
- Go to DNS.
- Create a DNS record for the
wwwsubdomain using the following values:
| Type | Name | IPv4 address | Proxy status |
|---|---|---|---|
A |
www |
192.0.2.1 |
Proxied |
It may take a moment for this DNS change to propagate, but once complete, you can run the following command in your terminal.
curl --head -i https://www.example.com/Then, inspect the output to verify that the location header and status code are being set as configured.