Setting up redirect from www to Apex Domain on Cloudflare in 2024 [with Screenshots!]

A guide on setting up redirect from www to Apex Domain on Cloudflare in 2024 with Screenshots!

Setting up redirect from www to Apex Domain on Cloudflare in 2024 [with Screenshots!]
Photo by Natalie Parham / Unsplash

In this article, I'll show you how you can set up a redirect from www to Apex Domain on Cloudflare. This one always throws me off while setting up a new project on Cloudflare, so here you have an article with screenshots!

In case you wanna check out my projects, they're this site, rocketrpc.com and sponsoredjobs.uk - the leading job site for visa-sponsored jobs in the UK.

Set up an A Record

Go to the DNS record settings for your website on Cloudflare by clicking on "DNS Records" on the home page, or clicking on DNS and then Records on the side-menu.

Add an "A" record with the name "www" pointing to content "192.0.2.1". This tells Cloudflare that you want to handle the www subdomain internally.

Set up Bulk Redirect List

This part looks confusing as it's in a completely different part of the Cloudflare dashboard. Go back to the home page at https://dash.cloudflare.com/.

Scroll the sidebar right down and click on "Bulk Redirects".

Scroll down on this page to see the option to "Create Bulk Redirect List". Click on it to create a new list.

Give any name and description, it's only for you to help navigate the list later. Once you see the option to add a rule here, add a redirect from www.<your_domain>/ to https://<your_domain>. In my case, I add the redirect below.

Click on next and eventually you should see the option to create an actual rule using the Rule List you just created. If you get redirected to the Bulk Redirects page again, don't worry, you can click on "Create Bulk Redirect Rule" now.

Add a name to your rule, choose the redirects list from the list, and hit "Save and Deploy"

Wait ...

Now is the most annoying part. You have to wait for Cloudflare to propogate these changes. It takes anywhere from 5 minutes to 48 hours because of how DNS works. Keep refreshing www.<your_domain> and it should eventually work!

If you followed all these steps and it didn't work yet, reach out to me on Twitter so I can have a look at your setup. Otherwise, you should also reach out to Cloudflare support to have a look!