Cloudflare DNS cannot redirect a domain to a URL path. The records resolve domain.com and blog.domain.com to an origin; the redirect itself is a Redirect Rule, which needs both hostnames proxied so the request reaches Cloudflare rather than going straight to the origin.

ℹ️ Redirects change the URL in the address bar. If the browser URL must stay put, that is a different mechanism (rewrite) — not DNS and not a Redirect Rule.

DNS: both hostnames proxied Link to this section

TypeNameTargetProxy
A@192.0.2.1Proxied (orange cloud)
CNAMEblogdomain.comProxied (orange cloud)

192.0.2.1 is a documentation-only placeholder, not a real server. A redirect-only setup can use a proxied placeholder record; with real hosting, point @ at the actual origin instead.

A CNAME at the root also works when the host gives a hostname rather than an IP — Cloudflare flattens it at the apex by default. @ and the literal domain.com are equivalent in the Name field, but never point @ at domain.com itself: that is a self-reference.

For the blog record use domain.com, not *.domain.com. The wildcard catches every other undefined subdomain and is not needed for one host. The CNAME controls DNS resolution only, not the HTTP hostname.

Root domain to another URL Link to this section

Rules → Redirect Rules → Create rule → Single Redirect:

  • Name: Redirect root domain
  • Custom filter expression:
1
(http.host eq "domain.com")
  • Target URL: https://destination.com
  • Status code: 301 (Permanent Redirect)
  • Preserve query string: enable if query parameters matter

This redirects every path on domain.com, not just the homepage. To redirect only the homepage, narrow the filter:

1
(http.host eq "domain.com" and http.request.uri.path eq "/")

Blog subdomain to domain.com/blog Link to this section

Second Single Redirect rule:

  • Name: Redirect blog subdomain
  • Custom filter expression:
1
(http.host eq "blog.domain.com")
  • Target URL: https://domain.com/blog
  • Status code: 301 (Permanent Redirect)

That sends every path to the same /blog target. To keep the path, so blog.domain.com/article becomes domain.com/blog/article, use a dynamic target:

1
concat("https://domain.com/blog", http.request.uri.path)

Enable query-string preservation in both rules if needed.

Before deploying Link to this section

  • Both DNS records must be Proxied (orange cloud). A grey-clouded record bypasses Cloudflare and no rule runs.
  • HTTPS must work for both hostnames; Cloudflare’s SSL/TLS settings need to cover the subdomain too.
  • Test with a temporary 302 first if the configuration might change — browsers cache 301 aggressively.

References Link to this section