The step-by-step guide to create a domain redirect with Cloudflare
Redirecting a whole domain using Cloudflare can be useful but isn’t documented anywhere, here’s how to do it.
Pre-requisite:
- Be logged into your dashboard.
Select the domain you want to redirect from
Go to page rules
Click “Create page rule”
Enter
your.domain/*
(matches all traffic) for which URLs will have their traffic redirectedClick “Add a Setting”
Select “Forwarding URL”
Select the type of redirect, I recommend 302s since they’re less aggressively cached (so if you ever want to use that domain to do something else other than redirect, you can)
Enter your forwarding URL
Click “Save and Deploy”
You’re done, you’ve just created a redirect from your domain to another one 🙂
Interested in Alpine.js?
Power up your debugging with the Alpine.js Devtools Extension for Chrome and Firefox. Trusted by over 15,000 developers (rated 4.5 ⭐️).
orJoin 1000s of developers learning about Enterprise-grade Node.js & JavaScript