Cloudflare’s 301 Redirects: A Step-by-Step Guide to Seamlessly Transition Your Content
Setting up bulk 301 redirects in Cloudflare is a crucial task when moving from an old domain to a new one, or whenever you’ve restructured your site’s content. These redirects ensure that users and search engines are directed to the right content, maintaining the usability of the site and the SEO value of your pages.
In this post, I’ll walk you through the steps needed to set up 301 redirects in Cloudflare. Importantly, I’ll cover an often-overlooked trick that ensures your redirects work correctly: pointing your CNAME records to
Getting Started with Cloudflare
Before we delve into the specifics of setting up 301 bulk redirects, make sure you have a Cloudflare account and your website is correctly set up in Cloudflare. If you are new to Cloudflare, you can create an account for free and follow the instructions to add your website.
Pointing your CNAME Records to 192.0.2.1
A key element of getting your 301 redirects to work correctly on Cloudflare involves configuring your CNAME records properly. While the typical approach is to point your CNAME records to your domain or subdomain, a trick to ensure that the 301 bulk redirect works correctly on Cloudflare is to point these CNAME records to
This seemingly arbitrary IP address is known as a “TEST-NET” address in the documentation of Internet Engineering Task Force (IETF). It’s designated for documentation and example purposes, which means it’s reserved and not routable on the internet. By using this, you’re essentially creating a placeholder for your CNAME record.
Here are the steps to update your CNAME record:
- Log in to your Cloudflare account and choose the site you want to work on.
- Go to the DNS settings page.
- Click Add Record.
- Choose CNAME as the record type.
- Enter the name of your subdomain.
- In the Target field, enter
- Set the TTL to Auto and set the proxy status to DNS Only.
- Click Save.
Please note, this change might take some time to propagate.
Setting up 301 Bulk Redirects
With your CNAME records correctly set, you can now proceed to set up your 301 bulk redirects. To do this, you’ll need to use Cloudflare’s Page Rules.
Here are the steps to follow:
- From your Cloudflare dashboard, select the appropriate domain.
- Navigate to the Page Rules section.
- Click Create Page Rule.
- In the field that appears, enter the URL pattern you want to redirect from. For example, if you’re redirecting from an old domain to a new one, your pattern might look like this:
- Next, you’ll see a dropdown labeled Then the settings are. Here, select Forwarding URL.
- In the next dropdown that appears, select 301 – Permanent Redirect.
- In the field labeled Enter destination URL, enter the URL you want to redirect to. If you’re redirecting to a new domain, your URL might look like this:
- Finally, click Save and Deploy.
This will apply the rule immediately. Please note that
$1 represents the first wildcard in your URL pattern, and this syntax can be expanded for more complex redirects. For instance, if you have a URL pattern like