How to redirect URL non -ww to www using cloudflare

Before we show how Redirect Non-Www URL to www USING Cloudflare, let's see why it is important that a website cannot be accessed both by www and without WWW (non-WWW).

There are many possessors of websites that insist on web developers on web addresses: “www.example.com“. Saying that this defines a site. That's right, this was many years ago, when many did not understand the true meaning of www.

In the technical terms of configuration of a web address, the prefix “www” It is only a subdomain as it is “abcd.example.com“. It has nothing special and only helps a web address with a greater number of characters. In fact, Google recommends in good SEO practices that websites do not contain www.

A real problem is when a web page is accessible both on a URL with www and one without www. In SEO practices it is called “Duplicate content” and is penalized. That is why it is indicated if a website does not use www, accessing https://www.example.com users to be redirected to https:/example.com, cu Redirection code 301. Code that means “Permanent redirection“.
It is possible that on www.example.com we have a website, and on example.com to have a completely different website. Hosted on different servers or on the same server.

If you already have a website with www in the URL, then it is advisable to leave it that way, but redirect 301 all the applications from non -www on www. If a visitor access the web page “example.com/demo.html” be automatically redirected on “www.example.com/demo.html“.

Redirect 301 usually Apache (.htaccess) or from the config NGINX of the domain. But it can be made very simple and from the account Cloudflare If you use this service as DNS Manager.

How to redirect URL non -ww to www using cloudflare

1.. The domain must have activated cloudflus. As well as DNS. Go first to settings DNS > Records and check that this service is active for A example.com and CNAME or A for www. Proxy status be active.

2. Go to domain settings in Pages → Page Rules. In the free version of the cloudflus you can set 3 rules for each domain. Create Page Rule.

Create Page Rule redirect in Cloudflare
Create Page Rule redirect in Cloudflare

3. The first field is introduced URL FARA WWW, followed by $1. https://example.com/$1. This means that the permalink redirection of all web pages is preserved. meaning https://example.com/abcd.html will be redirected to https://www.example.com/abcd.html. The user will reach the contents of the page.

At the rules settings will be chosen “Forwarding URL” and the redirection code will be chosen permanently 301.

URL of destination will be: https://www.example.com.

How to redirect URL non -ww to www using cloudflare
How to redirect URL non -ww to www using cloudflare

Save and Deploy Page Rule.

The new rule will enter the effect almost immediately.

This is the simplest method of redirecting the web pages and does not involve access or knowledge of .htaccess or ninx.

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. How to redirect URL non -ww to www using cloudflare
Leave a Comment