Redirect page rule not working without A record

I have defined a page rule where it should redirect to another URL but it is not working. When I open the website in browser, it throws error like the one you see when website doesn’t exist. I think it is because I don’t have any A record, AAAA record or CNAME defined in DNS.
But my question is why do I need A record (or CNAME or any other record) in DNS when I just want to redirect? I mean when a user types my website name in browser, the request comes to Cloudflare as I am using its DNS. And Cloudflare should see that a rule has been defined so it should redirect, right?
Or may be redirect rule works without any DNS entry and I am doing something wrong?

Not if you aren’t publishing any records that match the name your visitor is typing.

If your Cloudflare DNS domain is example.com and you have no record for test.example.com and I type that into my browser, my DNS resolver will ask Cloudflare DNS what address test.example.com resolves to. Cloudflare knows that your zone has no record for that name, so that is what it tells me. My browser would then display the relevant error page.

You have to an :orange: DNS record for Cloudflare to send visitors to the Cloudflare proxy. If you have no origin server, you don’t have to put in the IP of an actual server. The IP 192.0.2.1 from a range reserved from "TEST-NET-1" is a popular choice. RFC 5735 - Special Use IPv4 Addresses designates the 192.0.2.0/24 network for use in documentation and it should not be routed on the public internet.

So you are saying if I use IP 192.0.2.1 in my DNS as A record then it should work? I tried but it is not working. Screenshot given below.

If the redacted hostname is in the domain that you are redirecting with either a Bulk Redirect or Page Rule,and it matches the redirect rule, what you have shown will work. I have this method employed successfully on many domains.

You are correct. I was doing one mistake due to which it was not working.
I had added a rule to redirect www.mydomain.com but in DNS I had only entered A record without www that’s why it was not working. After I added CNAME record for www, the redirect worked.
I have now also added another rule without www so now I have two DNS entries (A record and CNAME record) and two rules (one with www and one without www) and both works.

1 Like