Easy Tech Tuts
Cloudflare

How to Redirect Non WWW to WWW in Cloudflare Easily 2026

By Impran M N

Consolidating traffic to a single version of your domain, either root or www, helps avoid duplicate content issues and keeps links consistent. This guide covers setting up a proxied placeholder record and building the redirect with Cloudflare's Rules engine.

01Add a placeholder A record

In DNS Records, add a proxied dummy A record for the apex root symbol '@' using the placeholder IP 192.0.2.1, which forces traffic through Cloudflare's edge rules.

02Open the Rules directory

Navigate to the Rules section in the sidebar and select Redirect Rules.

03Choose a redirect template

Click Create Rule and select the pre-made 'Redirect from Root to WWW' configuration template to auto-fill the required expressions.

04Review the redirect settings

Check the filter expression and forwarding destination, then set the status to 301 Permanent Redirect and enable query string preservation.

05Deploy and test

Click Deploy to activate the rule, then run a live access test to confirm requests to your root domain now forward correctly to www.

FAQ

Frequently asked questions

Why do I need a placeholder A record for this redirect to work?

Cloudflare's Redirect Rules only apply to proxied traffic, so the apex domain needs an active proxied record to route through the edge rules engine in the first place.

What's the significance of the 192.0.2.1 placeholder IP?

It's a reserved documentation IP address that doesn't route anywhere real, used purely to satisfy the requirement for a proxied record without pointing to an actual server.

Should I use a 301 or a 302 redirect?

A 301 Permanent Redirect is generally recommended for a root-to-www setup since it signals to search engines that the change is permanent.

Will this redirect preserve query strings and specific page paths?

Yes, as long as you enable the query string preservation option when configuring the redirect rule.

Watch the full walkthrough

The same steps, demonstrated on screen from start to finish.