How to forward or redirect domains on Cloudflare

This is a brief guide on how to redirect or forward from one domain to another on Cloudflare.
Step 1: Add the DNS records
First, let’s add the necessary DNS records.
On Cloudflare, navigate to the domain you want to redirect from and go to DNS > Records
. In this example, I will be redirecting my secondary “codecobalt.net
domain to my main codecobalt.com
domain.

Add an A record
for your root domain and point it to Cloudflare’s internal IP address.
Settings:
- Type:
A
- Name:
@
(for the root domain) - IPv4 Address:
192.0.2.1
- Proxy Status:
On / Proxied

Add a second A record
for the www
subdomain.
Settings:
- Type:
A
- Name:
www
- IPv4 Address:
192.0.2.1
- Proxy Status :
On/Proxied

When done you should have two records that look like this:

Step 2: Add the Redirect rule
Now, let’s add the redirect rule to the target domain.
Still on the domain you want to redirect from, navigate to Rules > Redirect Rules
.

Select Create Rule
and make a rule with the following settings:
- Name:
Redirect to codecobalt.com
(This is just a label. Replace with your domain name.) - If / When incoming requests match:
All incoming requests
- Type:
Static
- URL:
https://codecobalt.com
(Replace with your target URL)

Select Deploy
to commit your rule.
The rule should now show in your rules list.

Step 3: Test your rule
The rule is now in place and should work.
Navigate your browser to your redirect-from domain, and it should automatically redirect you to the new one (in my case codecobalt.net
takes me to codecobalt.com
).