Skip to main content

How to Redirect Domains in Cloudflare (www ↔ non-www)

This article explains how to create a permanent 301 redirect in Cloudflare so your www and non-www domains always resolve to a single destination.

Updated over 2 months ago

Confirm Your DNS Records in Cloudflare

Before creating a redirect, your DNS records must be configured correctly.

  1. Log in to your Cloudflare account

  2. Select your domain

  3. Click DNS in the top navigation

Required DNS Configuration

You must have two CNAME records:

  • Root domain (non-www)

    • Name: @ or your root domain

    • Proxy status: Proxied (orange cloud)

  • www version

    • Name: www

    • Proxy status: DNS only (gray cloud)

This setup is required because the www version is connected inside Kyrios under Settings > Domains.

Create a Permanent Redirect Using Page Rules

Cloudflare Page Rules control redirects using URL patterns.

  1. Click Page Rules in the top navigation

  2. Click Create Page Rule

Configure the Redirect Rule

URL Match Pattern

In the If the URL matches field, enter:

The * acts as a wildcard and captures all paths.

Redirect Settings

  1. Select Forwarding URL

  2. Choose 301 – Permanent Redirect

  3. Enter the destination URL:

$1 preserves the captured wildcard path.

4. Click Save and Deploy

Test the Redirect

  • Wait 2–5 minutes

  • Open an incognito/private browser window

  • Visit the non-www version of your domain

  • Confirm it redirects to the www version

Common Issues and Fixes

Funnel Error Code 500 (appendChild error)

If you see this error:

500 – Failed to execute 'appendChild' on 'Node'

This is caused by an incorrect proxy status.

Fix Steps

  1. Log in to Cloudflare

  2. Select your domain

  3. Click DNS

  4. Click Edit on the affected record

  1. Toggle Proxy status to DNS only

  2. Click Save

Allow a few minutes, then reload your site.

Pending Nameserver Status Warning

If Cloudflare shows a Pending Nameserver Update, redirects will not work yet.

What This Means

  • Your domain is not fully active on Cloudflare

  • Traffic cannot be proxied until nameservers are updated

Fix

  • Log in to your domain registrar

  • Replace existing nameservers with Cloudflare nameservers

  • Wait for activation (usually within 24 hours)

FAQ

What should I do if my redirect is not working?

Confirm:

  • Root domain is Proxied

  • www record is DNS only

  • Page Rule uses /* and $1

  • The rule is enabled

How long does it take for redirects to work?

Page Rules usually activate within minutes, but DNS propagation can take up to 24 hours.

Can I create multiple redirects?

Yes. Cloudflare supports multiple Page Rules, but:

  • Only one rule triggers per URL

  • Rules must not conflict

  • Free plans have rule limits

Should I use a 301 or 302 redirect?

Use 301 (Permanent Redirect) for domain redirects to preserve SEO and indexing.

Can I redirect www → non-www instead?

Yes. Reverse the URLs:

Ensure Kyrios is configured to use the destination version.

Do I need an A record if I’m using CNAMEs?

No. Cloudflare supports CNAME Flattening, allowing CNAME records at the root level.

Did this answer your question?