Skip to main content
Photo of DeepakNess DeepakNess

Redirect subdomain to a URL in Cloudflare

Unproofread notes

I had to redirect a subdomain of my domain to an external domain, and here's how I did it using Cloudflare Redirect Rules:

Here, I will take the example that I have to redirect test.deepakness.com to the https://rohit.online URL.

Step #1: Create a new CNAME DNS record with the following details:

  • Type: CNAME
  • Name: test
  • Target: deepakness.com
  • Proxy status: Proxied
  • TTL: Auto

Step #2: Create a new rule by clicking on the Create rule > Redirect Rule button by going to the Rules section, and then fill in other info as per below instructions:

  • Rule name: As per your preference
  • If
    • Incoming requests match: Custom filter expression
    • Field: Hostname
    • Operator: equals
    • Value: test.deepakness.com
  • Then
    • Type: Static
    • URL: https://rohit.online
    • Status code: 301
    • Preserve query string: Checked
  • Place at
    • Select order: First

I wish I knew this from earlier.

Webmentions

What’s this?