Set Up a 301 Redirect Through Cloudflare, Step by Step
Moving to a better domain name? Here's how to set up a 301 redirect with Cloudflare so your old links, search ranking, and customers all land on the new name.
Say you bought a shorter, easier-to-say domain for your business. Smart move. But now you have a problem: people still have your old address saved. It's on business cards, old invoices, your Google listing, and plenty of links around the web. If you just switch sites, all of that breaks.
A 301 redirect fixes it. A 301 tells browsers and Google, "This address moved for good. Send everyone to the new one." Done right, your old links keep working and the ranking you earned follows you to the new name.
This guide shows you how to set up a 301 redirect with Cloudflare. It's free, it's reliable, and you don't need to be technical to follow along. Give yourself about 30 minutes the first time.
Why Cloudflare for this
There are a few ways to redirect a domain. Some registrars offer simple forwarding, but it can be slow or drop parts of the web address. Cloudflare sits in front of your domain and handles the redirect fast and cleanly. It also lets you keep every old page pointed at its matching new page, which protects more of your search ranking than dumping everyone on the homepage.
If you want the reasoning behind that last point, read Redirect to Homepage or Matching Page? Where 301s Preserve the Most Authority. It's worth two minutes before you build this.
What you need before you start
- Your old domain (the one you're moving away from).
- Your new domain and a working site on it.
- Access to the account where your old domain is registered, so you can change its name servers.
- A free Cloudflare account.
One thing to be clear on: you're adding the old domain to Cloudflare, not the new one. The old domain is the one doing the redirecting.
Step by step: set up a 301 redirect with Cloudflare
1. Add your old domain to Cloudflare
Sign up at Cloudflare and choose "Add a site." Enter your old domain. Pick the free plan. Cloudflare will scan your existing DNS records and show you a list. You can leave these as-is for now.
2. Point the old domain's name servers to Cloudflare
Cloudflare will give you two name server addresses. Go to wherever your old domain is registered, find the name server settings, and replace what's there with Cloudflare's two. Save it.
This change isn't instant. It usually takes a few minutes to a few hours to go live, sometimes longer. Cloudflare will email you when your domain is active. For the exact steps at your registrar, Cloudflare keeps a clear help page here: https://developers.cloudflare.com/dns/zone-setups/full-setup/setup/.
3. Make sure the old domain has a DNS record to catch traffic
A redirect needs something to grab the request before it can send it on. In Cloudflare's DNS tab, make sure you have an A record for your old domain. A common approach is to point it at a placeholder IP like 192.0.2.1 and turn on the orange cloud (proxied). The orange cloud is what lets Cloudflare step in and do the redirect. Add the same record for the www version too.
4. Create the redirect rule
In your old domain's dashboard, go to Rules, then Redirect Rules, and create a new rule. Here's a simple setup that keeps each old page pointed at its matching new page:
- When incoming requests match: choose "All incoming requests," or match by hostname if you want to be specific.
- Then: choose a Dynamic redirect.
- Expression: use concat("https://www.yournewdomain.com", http.request.uri.path). This carries the page path over, so oldsite.com/services lands on newsite.com/services.
- Status code: choose 301. This is the part that makes it permanent. A 302 is temporary and does not move your ranking the same way.
Save and deploy. The difference between those two codes matters more than it sounds. See 301 vs 302 Redirects: Which One Protects Domain Authority? if you want the short version.
5. Test it
Open a browser and type your old domain. You should land on the new one. Now test a deeper page, like oldsite.com/about, and confirm it goes to newsite.com/about. Try the www and non-www versions both. Fix the rule if anything lands in the wrong place.
Common mistakes to avoid
Two problems trip people up most. First, redirecting everything to the homepage instead of the matching page. That throws away ranking you could have kept. Second, stacking redirects so a request bounces through two or three hops before it lands. That's slow and it leaks value. Our guide Redirect Chains and Loops: How They Quietly Leak Domain Authority shows how to spot both.
For a fuller checklist before you go live, 7 Common 301 Redirect Mistakes That Kill Domain Authority is worth a read. And if you'd rather do this at the registrar or host level instead of Cloudflare, How to 301 Redirect an Old Domain to Preserve Its Authority walks through the other options.
Setting up the redirect is the technical half of moving to a better name. The other half is picking a name worth moving to in the first place. If you're still weighing that, browse names for your city and trade on PixelWorks Domains, or ask us about one specific domain you have in mind. Either takes under a minute.