Tutorial

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.

By Code CobaltJanuary 1, 2024
How to forward or redirect domains 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. Cloudflare DNS records empty 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
Cloudflare DNS root A record Add a second A record for the www subdomain. Settings:
  • Type: A
  • Name: www
  • IPv4 Address: 192.0.2.1
  • Proxy Status : On/Proxied
Cloudflare DNS root www record When done you should have two records that look like this: Cloudflare DNS records complete

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. Cloudflare redirect rules empty 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)_
Cloudflare redirect rule settings Select Deploy to commit your rule. The rule should now show in your rules list. Domain redirect in Cloudflare

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).

Ready to get started?

Let's discuss how we can help bring your digital vision to life. Get a free consultation or request a custom quote.

Or email us at contact@codecobalt.com