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
| Type | Name | Target | Proxy |
|---|---|---|---|
| A | @ | 192.0.2.1 | Proxied (orange cloud) |
| CNAME | blog | domain.com | Proxied (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
Rules → Redirect Rules → Create rule → Single Redirect:
- Name:
Redirect root domain - Custom filter expression:
| |
- 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:
| |
Blog subdomain to domain.com/blog
Second Single Redirect rule:
- Name:
Redirect blog subdomain - Custom filter expression:
| |
- 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:
| |
Enable query-string preservation in both rules if needed.
Before deploying
- 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
302first if the configuration might change — browsers cache301aggressively.