Wildcard problem in Page Rules not working

hello Cloudflare community

please guys i have problem with Rules option
i want to redirect all traffic coming from any random subdomain to an external website
i create new rules with this condition

URL (required) : *.example .com
Enter destination URL (required) : external example .com

i created also another rule with this condition:
URL (required) : .example .com/
Enter destination URL (required) : external example .com

but no one of this condition work and i really dont know why

my question is do I need to add any record in DNS table to make these rules work ??

like CNAME with wildcard (*) or in page rules it’s not necessary to add any DNS record


anyone here can help us ???

Short answer, yes.

If they don’t exist, then the rule shouldn’t either apply for them.
You’d get the expected DNS_PROBE_FINISHED_NXDOMAIN error at first sight.
I’d say don’t even bother adding each of them to the DNS tab.

From some example cases, this wouldn’t work as expected :thinking:
If so, you might be missing what comes after .com, so a better version to match would be *.example.com/*, where even the www if you’re using it, which isn’t so great. :thinking:

To fix www, you’d have to use 2 Page Rules, where 1st would be the www redirect to non-www and then the 2nd rule *.example.com Forwarding URL 301 Redirect to othersite.com.

For further cases, keep an eye, the specific order has to be made of the Page Rules to make an exception for www (if so) to make it work. Also, make sure your example.com or any other sub-domain for which you’d like to apply Page Rules (hostname (DNS record) ) is proxied :orange: .

Helpful article:

sorry but i didnt got you my problem is just i want to redirect all wildcard subdomain traffic to other static page only to one page so it not problem if ididnt send same path to redirection URL

what happend with me is when i this one *.example.com/* or this one `*.example.com/ the Rules its not working at all website is down

May I ask, have you got any sub-domain hostname added as a DNS record under the DNS tab of Cloudflare dashboard? :thinking:

no i dont have any subdomain the record table has just one A record for main domain

Then it’s expected behaviour to see an error in your Web browser, because there is no route to the sub-domain as it doesn’t exist at all.

Oh thats mean i need to add an wildcard in DNS table as Subdomain A record??
and should i add any IP right ??

Tehnically, yes.

Here’s how to do it:

More information about it here:

Despite, again, personally and from experience and other topics and issues customers have had, I am not for doing that at all. You could use :search: to find them.
Just one example, when customers moved their domain to Cloudflare, and they already have had * wildcard DNS record, in the process of scanning the existing DNS records, it created a bunch of unwanted and unknown DNS records which had to be manually removed, which of course consumes time and customer didn’t knew which sub-domain he/she had to continue using vs which are just surplus etc.