Cloudflare Docs
Pages
Visit Pages on GitHub
Set theme to dark (⇧+D)

Redirecting www to domain apex

In this guide, you will learn how to redirect the www subdomain to your apex domain (example.com). This is a common question and can be achieved by using Bulk Redirects.

To do this:

  1. Log in to the Cloudflare dashboard, and select your account and website.
  2. Go to DNS.
  3. 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.

Add a www record in the Cloudflare DNS dashboard

  1. Next, go to Account Home > Bulk Redirects > Create a new Bulk Redirects list > Create new list.

Create a new Bulk redirects list

  1. In the content type, select Redirect.
  2. Add your redirect Source URL and Target URL. Your target URL must include https:// before the apex domain.
  3. Select Edit parameters > select Preserve query string, Subpath matching and Preserve path suffix.

Follow the steps above to correctly configure your list

  1. Select Add to list.
  2. Go to Bulk Redirects > Create Bulk Redirects > select your list > Save and Deploy.

Create a new Bulk redirects

To test that your redirect worked, go to the Target URL and double-click the URL as if to copy it. If the URL does not display www, your change has successfully propagated.