"This Post contains affiliate links; we earn commissions if you shop through the links on this page."
Here is the step-by-step process if you’re looking for an easier way to permanently 301 redirect www to non-www URL version in your Cloudflare account.
You won’t find complicated theories here. This is not more than three clicks to get it right.
And you’re done.
This process does not involve adding code to htaccess files or accessing your website files through an FTP program. It is a simple three clicks step to fix how I redirect www to non-www URLs.
But it will only work if you’re using a Cloudflare domain name server with your web host and want to redirect Cloudflare www to non-www URLs.
Before diving into the actual steps, we must explore the differences between the www URL prefix and non-www.
Should you prefer one over the other? What are the pros and cons, and which one should you set as the selected domain URL version?
If one URL version is at all beneficial over the other.
Table of Contents
A bit of Background History
At the earliest stage of the internet, when www was a massive thing, people often typed www at the start of a website address.
The www (world wide web) letters were synonymous with the internet.
When people say www, you’d think they’re talking about the entire internet.
I was thinking like that, too 😜
As time goes on and more people are now familiar with the internet, website users realize they don’t need the www prefix to reach a website.
So, they started typing website addresses without the www at the beginning.
Webmasters noticed this trend and think it’s best to set the non-www address as the preferred URL version of a website.
A new form of SEO issues begins.
For search engines like Google, not setting the preferred domain URL prefix will lead to duplicate content issues. This is because search engine crawlers see www.yourwebsites.com as a different domain from https://yourwebsite.com.
To a search engine, these are two different domains entirely.
To fix this type of duplicate content issue in the search engines, you only need to specify which URL version is the preferred one.
And before that, you must verify all versions of your website URL in the Google search console property. So, Google and other search engines alike will understand that irrespective of the URL prefix, they’re all one domain.
More on setting your preferred or canonical URL down the post.
WWW vs. Non-WWW Which one is better for SEO?
For most website owners – small businesses and individuals – there is nothing to worry about regarding the SEO benefits between www and non-www URLs.
It’s just a matter of personal preference and what users find comfortable. There are no significant SEO benefits to using one over the other.
The only rule is to stick to one and be consistent with it. If you prefer the www prefix, stick with it, and if the non-www is your choice, that’s fine.
However, there are slightly technical benefits that come with www over non-www. But this is to be considered if your website receives millions of page views daily.
For clarity and honesty, let’s take a brief look at these technical benefits of www over non-www web addresses.
Advantages of www over non-www URL version
As mentioned earlier, if your website receives millions of daily hits, you may benefit from using www as the URL prefix.
This is because it’s easier to direct traffic to other servers if one gets overwhelmed by an inflow of website traffic.
Also, the www URL allows you to use a cookie-free domain, which helps reduce the number of HTTPS requests to boost performance.
To learn more about the pros of using www in your URL, here is a website dedicated to the subject.
Why Should You use non-www?
First, www is obsolete in the face of today’s web users. I can’t remember the last time I typed www before a web address.
Do you still type www before a website address?
It’s unnecessary to type www to reach a URL. The non-www URL version of a website is easier to type, remember and say verbally.
Removing www from your web address brings more brand consistency across marketing channels. This is because you don’t have to remember what you need to type – type your domain name with the extension, and you’re good.
If you never need to restrict cookies on your domain, you can opt for a non-www URL prefix. And if your website does not get millions of visits daily, you have no business thinking about www.
Read this comprehensive post to learn more about why you should drop www from your website URL.
Duplicate Content and WWW or Non-WWW URL
If the content on a different URL is the same, Google considers this as duplicate content.
To search engines, www.yoursite.com is different from https://yoursite.com, so this causes duplicate content issues.
Before 2019, Google wanted you to set the preferred URL version in the Google search console, but that’s a thing of the past.
You no longer need to do that in the search console anymore.
Google announced you could use one of these four communication methods: your preferred or canonical index URL.
- Submit a Site with the preferred URL Version
- 301 redirect to preferred URL prefix
- Use rel=”canonical” HTTPS header
- Use rel=”canonical” link tag on HTLM Pages
The website URL version you specify will be the one Google will crawl and have in its index.
Do not submit an XML sitemap for www and non-www versions of your site, as this will lead to duplicate content issues.
If you need a more advanced guide on setting the canonical URL for your website, read this helpful documentation on the Google website.
How to Redirect www to non-www URL in Cloudflare
The process described here only applies if your website is added to Cloudflare and uses the domain name server – DNS.
Log in to your Cloudflare account and click on the domain you want to 301 redirect www to non-www URL version, then follow the steps below.
1. Page Rules
Click on Rules from the top navigational menu link in your Cloudflare account. If you’re on the free plan, you have only three-page rules to use. You must use your option wisely.
Click the “create page rule” button on the next page.
2. Set up 301 Redirect WWW to Non-WWW
This is where you set up the 301-redirect www to non-www in Cloudflare.
In the first input field, enter your website www URL version – www.yoursite.com (do not forget to add the asterisk at the front of your URL like in the image below.
Select the forwarding URL from the drop-down menu and 301 permanent redirects from the second drop-down menu.
Next, enter your naked URL – https://yoursite.com – in the “enter destination URL” field. Note: add the $1 symbol in front just the way it is in the image below.
Next, click on the “Save and Deploy” button. That’s it; from now every traffic to www.yoursite.com will redirect to https://yoursite.com.
While www is out of fashion, it does have some slight technical advantages you might want to consider if you’re a big website.
For most websites, doing away with www will bring more benefits, help with branding, and improve user experience.
Also, it’s more convenient to type without the www prefix into the address bar. But whatever your URL version of choice, there is only one rule:
Pick one URL version, redirect the other to it, and stick with it. It does not help to change your domain’s canonical URL after setting one as the preferred version.
4 thoughts on “How to 301 Redirect www to non-www in Cloudflare”
It was a great share! My friend has recently set up a website. I think 301 redirects are a common problem, and people often don’t know how to correct it. I have a friend who uses Cloudflare and since he is new to using it, he does not know much about all this. I think this article will help a lot of people. I really loved how you covered all the important aspects of this article. It will definitely help him, and several people like him who are new website owners.
Good to hear from you again. 301 redirect is a common issue for website owners – especially beginners. I hope this helps resolve the issue. Thank you.
Nice article, it helps me a lot about 301 redirects. Thanks for sharing