Deprecated - Redirect www.example.com to example.com

This tutorial is deprecated in favour of Redirect examples · Cloudflare Rules docs

Archive

This tutorial covers redirecting www.example.com to example.com when using Cloudflare, to do the opposite, please see Deprecated - Redirect example.com to www.example.com.

You should replace all instances of example.com in the screenshots with your domain.

Step 1, The DNS Record:
The first thing you will need is a DNS record for www, set to :orange:. This can point to any IP address as the redirection page rule will execute first. I would recommend pointing it to 192.0.2.1, a dummy IP.

image

Step 2, The Page Rule:
The second step is the page rule that will perform the redirect. You should add one like this:

The * means it will forward all pages and the $1 will keep the path, i.e. if you typed in www.example.com/page1, you would be redirected to https://example.com/page1.

Note about redirect types: This tutorial shows a 302 Temporary Redirect, I would recommend starting with this and checking it functions as required. Then if you intend to keep the new location permananely, switch to a 301 Permanent redirect.

Introduction to redirecting with page rules video

https://youtu.be/gvPfNfiFESo



Tutorial Reference: CT-28

Reviewed: 08/21

This is a Community Tutorial, most are wiki posts, so can be contributed to by Regulars and MVPs here. If there is a tutorial you would like to see, you can request one here.

If you would like to provide any feedback on this tutorial, please post in the #Meta category, tag your post #TutorialFeedback and let us know the Tutorial Reference above.

Other great resources on this community include the Community Tips . These address best practices when configuring Cloudflare, how to fix issues you may see, and tools to troubleshoot. Also you can view Expert Tips, great posts on the community from people in the know that may help you with your issue.

We encourage users to check out these great resources and the Cloudflare Support Centre before posting


11 Likes
DNS Issue with WWW
Can't access site using www
Website doesn't open with WWW
Cant access my wordpress site with www
Community Tutorials
Add an A, AAAA, or CNAME record for www so that website will resolve
WWW and Without WWW
WWW subdomain will not work
Add an A, AAAA, or CNAME record for
What page rule can I set up for www & https
Error 523 on a few different sites
How to redirect www to non-www for Subdomains
Www. takes me to the wrong version of my site
SSL DRAMA: A Love Triangle Between SquareSpace, Wordpress, and GoDaddy
How to direct old www site to new https site
Website not loading with "www" in URL
Is it possible to have 'www' resolve to subdomain?
Pending Nameserver Update 5555
Is Cloudflare service down? Status says ALL FUNCTIONAL
Will Cloudflare change my host to www?
Worker DNS setup
Redirect https domain to https domain doesn't work
Your connection is not private on www
Site goes offline when cloudflare is activated
HELP with Error 502 Cloudflare
Download emails
Setting CNAME Record To Map to My Own Domain for Podbean podcast
CNAME `www` not resolving
Unable to open website using adservs.in/www.adservs.in or http://adservs.in/http://www.adservs.in
How to convert my site into world wide web format
CNAME error when hosted by Bluehost
Unsecured website (https is crossed out)
أعد توجيه example.com إلى www.example.com
Cloudfare not operational with www links
Wildcard subdomains with custom certificate not working with Heroku
Redirecting All traffic to Another Domain
A record is different from dnschecker.org
Is the new Transform Rule the same as ReWriteCond on?
Changes not reflects in WWW
For my domain entry I see CNAME flatterning message next to my CNAME
Everything's working on our side, so the link you clicked is either wrong or has been retired
I want to open my domain without www , please
Desperate help needed setting up DNS, can't figure it out
Redirect non www to www using
I changed DNS to CloudFlare but my website is not running
WWW and non-WWW
Important information about relation between dns chance and seo
Blocked font by cors policy: no 'access-control-allow-origin'
I don't get why there are "Zones"?
How do I change the DNS A records for my domain to resolve to a different IP address?
Error 1000 despite using correct IP
Trying to redirect my domain to subdomain & add https to subdomain
Getting the CNAME for www
How to redirect "www" to "non-www" domain?
The Speed test could not run and getting 404
My CNAME point an old DNS record
Non-www redirect to www not working. Could u pls help me?
How can i do 301 redirect
Lien entre une page cloudflare et un domaine OVH
Delete a domain (remove it)
Assistance With IPFS SetUp :)
Problems setting up my domain on Cloudflare
Site can't be reached when using www
Www still redirecting to old web host
Creating a subdomain that redirects to another website
Page rule not working for domain without www
Setting up a redirect
Getting Origin DNS error
Configuration problems
404 Error when I add www
How to add a CNAME record for www so that www.domain.tld will resolve
IP address changed! Am I fixing it correctly?
DNS records not showing up
Failed to perform lookup using WHOIS service: TLD_NOT_SUPPORTED
Redirect from www to non www. How to stop to increase site load speed?
Beginner question - regarding domain mapping
Error when sharing my site to Instagram and Facebook
Custom Domain Name / Heroku / Cloudflare not working together
A record info
Newbie to Cloudflare - check Proxy status
CNAME no longer working - newbie
DNS management HELP
CNAME not resolving for www
Redirect Subdomain to main domain
Hubspot to Shopify migration problem
Traffic restrictions on the free plan
How To Add www
SSL www vs promax .me
Domain Redirect Not Switching Back
Clickfunnels www domain not redirecting to domain
Redirect www subdomain to apex at the DNS level?
526_error for our domain
Redirect dosen't work from www.example.com/fr to example.com/fr
Issues with DNS - type out www
How to redirect immediately to HTTPS://WWW (without redirect chain)
Page rule subdomain redirects not working as expected
URL Redirected too many times
Www record not working
How to add CNAME for gitbook : Error 1014
How to create a page for subdomain
Cloudflare Pages With Google Domain: https root domain
DNS CNAME Record Point
Website showing strange error "Please Surf Safely! This website is prohibited for viewership in Pakistan." when using www in URL, but loading fine without www in URL - (designstudio.com.pk)
DNS_PROBE_POSSIBLE without www
WWW to non WWW site
WWW subdomain doesn't resolve
Right dns settings for workers
Unable to visit domain with prefix
Www. not working
404 error - leadersfactor.com
Redirecting the subdomain to a different www address
Domain is weird
Nginx redirect from www to a base domain doesn't work when proxied via cloudflare
2365995 - Account Dash Ticket - CNAME ERROR
Website can't access from specific country
Redirect Page Rule Not Working
Что делать? DNS_PROBE_FINISHED_NXDOMAIN
Blogger just open without www
Subdomain redirect to the main domain
Add an A, AAAA, or CNAME record for **www** so that **www.domainname.com** will resolve
CNAME dns "www" doesn't work on my domains
.IT Domain name servers not changing
WWW - can I delete it?
Cant redirect www DNS to either new page or main page withou WWW
Www.blog -> .blog
Been over 24 hours, site not working still
Www part of website not working
Site not forwarding if www left off
How to redirect my website from https to https://www
Add www version
Page Rule is not working for me
Add WWW to domain with no website
Redirecting http to https
Domain redirection from one to another
Deprecated - Redirect example.com to www.example.com
Deprecated - Using page rules to perform redirects
Redirect the www to non-www
DNS Record disappears again
Website giving Error 1000, but IPs in DNS are not showing a prohibited IP
Updating DNS records to enable hosting
I want to make from www.domain to non-www.domain, i don't know what to do
Cloudflare DNS records not updating (almost 24 hours later)
Error 526 since Google Workspace configuration added
URL Forwarding: non-unique match wildcard redirect
SubDomain - 404 Error - Blog
WWW Redirection For New website
Www CNAME can’t be proxied through cloud flare
DNS Only records
Www.domain.com to domain.com not working
Redirected WWW to nonWWW issue
Add an A, AAAA, or CNAME record for **
Www CNAME DNS setup
How to create a basic www DNS CNAME Record
Cloudflare Pages DNS Configuration
Secure Connection Failed when redirecting from www to naked domain
Performance of site over www redirect
How to add an A record to the DNS
Www not redirecting to main domain
I can't setup correctly DNS
Problem with the SSL installation
Problem with the SSL installation
I can't setup correctly DNS
Requests Through Cloudflare - Only a Fraction Passing Through Coudflare
Issue with sitemaps in serach console and indexing