Ensuring Smooth Redirects: Manual www to Apex Domain Setup on Cloudflare - Waiviogit/waivio GitHub Wiki

When managing your website's domain settings, it's common to want a cohesive user experience by redirecting the www subdomain to your apex domain. Setting this up correctly via Cloudflare ensures that visitors access your site seamlessly, regardless of the URL they enter. This guide will walk you through the two fundamental steps to properly configure the www-to-apex redirection:

I. Setting Up or Modifying the DNS Record

  1. Log in to the Cloudflare dashboard.
  2. Select your domain.
  3. Navigate to the DNS section and then the Records page.
  4. Look for a record with the name "www".

image

  1. If a "www" record exists: 5.1. Click Edit.

    5.2. Decide if you're basing the record on IPv4 or IPv6. Either will work.

    5.3. Choose the type:

    "A" and enter "192.0.2.1" in the "IPv4 address" field (for IPv4)

    OR

    "AAAA" and enter "100::" in the "IPv6 address" field (both options are functional, so choose based on your preference or needs).

    5.4. Ensure the name remains as "www".

    5.5. Click Save.

image

  1. If a "www" record does not exist: 6.1. Click "Add record".

image

6.2. Choose the type:

 "A" and enter "192.0.2.1" in the "IPv4 address" field (for IPv4)

OR

"AAAA" and enter "100::" in the "IPv6 address" field

(Both options are functional, so choose based on your preference or needs).

6.3. Set the name to "www".

6.4. Click Save.

image

II. Configuring Redirection Using Bulk Redirects

  1. Exit the domain configuration.
  2. Access the main dashboard.
  3. Navigate to Bulk Redirects.
  4. Click on "Create Bulk Redirects List".

image

  1. Provide a name for the list and click "Next".

image

  1. Select "Or, manually add URL redirects".
  2. For the Source URL, enter your full domain with the "www" (e.g., www.example.com).
  3. For the Target URL, input the original domain, including "https://", and without "www" (e.g., https://example.com/).
  4. Click "Next".

image

  1. Choose "Edit parameters".

  2. Activate the following checkboxes:

    • Preserve query string

    • Subpath matching

    • Preserve path suffix

image

  1. Proceed by clicking "Next".
  2. Click on "Continue to Redirect Rules".

image

  1. Provide a rule name.

  2. Click "Save and Deploy".

image

Now, when you enter your domain with "www", it should redirect to the main domain.

For more detailed information and potential troubleshooting, you can refer to the original documentation from Cloudflare https://developers.cloudflare.com/pages/how-to/www-redirect/.