How to redirect from www to non-www URL using Cloudflare for free

sign showing direction on city street

After doing a quick SEO audit to this website, I found that https://davidloor.com/ and https://www.davidloor.com/ were both up. Since search engines see them as two different websites, it may arises issues because of duplicated content. So, I needed to pick one of the domains and redirect the other to the one selected. On the internet there is a big debate about which version is better, but I like the non www because it is shorter, also this website is simple and there is not too much content in it yet, but in bigger websites I may be inclined to use the www version.

This website has cloudflare as its CDN, so the steps to add a page rule to accomplish the redirect are as follows:

1.- Log in to your Cloudflare account from https://dash.cloudflare.com/login and go to the domain that you want to add the redirect to in case you have more than one.

2.- Go to Rules -> Page Rules and click on Create Page Rule

Create Page Rule

3.- Enter the URL that you are redirecting from, in my example, I am need to enter the www version (www.davidloor.com)

4.- Pick the Forwarding URL setting and the status code should be 301 – Permanent Redirect

5.- In the destination URL field we should enter the URL that we are redirecting to, adding /$1 at the end, in my example it is the non www version (https://davidloor.com/$1)

6.- Click on Save Page Rule, and go to your website to test that the redirect is working. It should work almost immediately.


Posted

in

, ,

by