How to Redirect a Domain with Cloudflare Pages
Cloudflare offers free hosting for static sites through a service called Cloudflare Pages. This tutorial shows how to use the free hosting service to redirect entire domains or subdomains in an SEO-friendly way, without using up your Cloudflare Rules.
This technique is free and works whether you have registered your domain through Cloudflare (about $10/year) or through another registrar.
Step 1: Set Up Your Domain with Cloudflare
If you registered your domain through Cloudflare, this step is already done.
If you registered your domain elsewhere, go to cloudflare.com, create an account, and add your domain on the free plan. The site will walk you through all of the steps.
Step 2: Create a _redirects File
Redirects on Cloudflare Pages are done with a _redirects file.
Create a new folder on your computer for your Cloudflare Pages files. Only files that will get uploaded to Cloudflare should be in that folder.
Inside of that folder, create a file named _redirects (no file extension). To redirect every path of a domain to to its corresponding path on another domain, use this syntax, replacing example.com with the destination domain:
/* https://example.com/:splat 301
The asterisk captures the path (e.g., about, contact, blog/my-post/) and inserts it into the placeholder named :splat.
An advantage of using a _redirects file is that you can be very specific about how you want to redirect things by adding more rules to the file. In this example we’re only doing a simple redirect from one domain to another though.
For more information on the _redirects syntax, see the Cloudflare Pages redirects documentation.
Step 3: Add Cloudflare Pages
Go to dash.cloudflare.com and click on “Pages” in the left sidebar.
Then click on the “Create a project” button. It should give you three options, as shown in the image below.

If you are comfortable with a terminal or Git, you can use Wrangler (NPM) or Git, but for this tutorial, I’ll explain the direct upload method, because it’s the easiest.
Upload the folder containing the _redirects file using the instructions on the page:

After submitting the upload form, your files will be online on a subdomain of pages.dev. The next step is to add your custom domain.
Step 4: Add the Custom Domain
From your overview page in Cloudflare Pages, you should see a tabbed menu, something like the image below. Look for the tab that says “Custom domains” and click that.

On the following page, add your custom domain or subdomain. The domain must be registered in Cloudflare already. (See Step #1 above.)
In the screenshot below, I’m adding a subdomain that I’m going to delete after I finish writing this tutorial:

Once you activate the domain with the blue button, your redirects will be live. Take a few minutes to look around the settings in the dashboard to ensure that everything looks correct.
The last step is to check your HTTP headers and verify that they are sending the correct status codes.