How to set rules in Cloudflare, www redirect to non-www

  • Date:
  • Category: Tips

We don't want to use the subdomain "www", but if the visitor accesses through the subdomain "www", we want to use the rule to redirect the request to the non-www domain. How should I set it up on Cloudflare?

In Cloudflare, we set the domain "Rules", and go to "Page Rules", click "Create Page Rule".

Rules

URL: www.yourdomain.com/*

Pick a Setting: Forwarding URL

Select status code: 302 - Temporary Redirect

Enter destination URL: https://yourdomain.com/$1

In the DNS settings, you need to set the resolution of the "www" subdomain, and you need to set the "Proxy Status" to "Proxied". The cloud needs to be orange.