Try any GetResponse Plan for free. No credit card required

How to redirect non-WWW URLs to WWW using Cloudflare

Here’s how to redirect the non-www URLs of your website to the www version using Cloudflare without touching your .htaccess file. Most of the websites are accessible using both, the non-www URLs and the www URLs. But usually, people don’t prefer that in order to comply with the best SEO practices. This is because search engines consider URLs with and without “www” as two different websites or duplicate content and this can lead to a penalty.

NOTE: This post applies only to people who are using Cloudflare as their content delivery network (CDN) and DNS manager aka Cloudflare users.

Step 1 –

Login to your Cloudflare account on which the website for which you want to set redirects is active.

Step 2 –

Click on the ‘Page Rules‘ tab in your Cloudflare dashboard. It should look something like this 👉Cloudflare Pagerules

Step 3 –

Then click the ‘Create Page Rule‘ button. Set the page rule as ‘Forwarding URL‘. Now have a look at the screenshot below and replace ‘’ with your own website’s domain name and extension.

redirect non-www to www urls settings for cloudflare

Step 4 –

Once you’ve replaced ‘’ with your domain name, hit ‘Save and Deploy‘. Make sure that you have set the forwarding type as 301 – Permanent Redirect. Also, set the Order (not seen in the pic but you will be given that option when adding the page rule if you’ve already set any page rules before this) as First. This is the order in which your Page Rules will be triggered. Only one Page Rule will trigger per URL, so put we must put this page rule at the top.

Step 5 –

We are nearly done but just to clear the previous settings, purge your cache (though it’s not absolutely necessary) from your Cloudflare dashboard. To test if it is working properly, clear the saved files and cache from your browser and then try visiting the non-www URL of your website from the address bar and you will find it automatically getting redirected to the www version by default.

That’s it. Now all requests to the non-www version of your site will be getting redirected automatically to the www version. Rest is handled by Cloudflare.

If you still insist on creating the redirection with the help of .htaccess file, then follow this tutorial by SiteGround.

Caution: Download a backup of your .htaccess file before making any changes to it. Any misconfiguration in the .htaccess file can lead your whole website to crash!

Also Read: How to Serve Compressed Emoji in WordPress.

23 thoughts on “How to redirect non-WWW URLs to WWW using Cloudflare”

  1. Pro tip: Instead of making the forwarding destination ‘’, make it ‘$1’. That way visits to ‘’ will take you to ‘’ instead of ””


    • Wait for the page rule settings to propagate across Cloudflare’s servers. Also, you can try clearing your browser’s cache in addition to Cloudflare’s own cache files and then try again. Hope you are able to get it fixed.

  2. Thank you so much for this. I struggled for hours trying to do what could be done in 5 minutes with the right information.


Leave a Comment