Do page rules work with Cloudflare Pages?

I've tried deleting and recreating page rules but none seem to work, do they not work with Cloudflare Pages? For example, i'm trying to redirect www.domain.live to domain.live and it doesn't work
15 Replies
simpson
simpsonOP15mo ago
I have the domains setup in a single Cloudflare Pages project I tried without that in the destination and still nothing
aaaaaaaaaaaaaaaaa
I think your destination URL needs to be https://[your-domain].live/$1 By the way the domain name is at the top of the screenshot.
Chaika
Chaika15mo ago
As others have said, you would need to use $1 to use the wildcard match, not * You also need a DNS Record created for the page rule to work. For originless records (i.e you're just using redirects), Cloudflare recommends 100::. Create the following record: AAAA www 100:: Proxied and then wait a bit for DNS cache to expire. (100:: is IPv6 Discard, basically saying if you don't match any of the rules to handle a response, don't go anywhere. If you see a 522, you didn't match anything) Pages also has a guide on doing this with Bulk Redirects instead of Page Rules: https://developers.cloudflare.com/pages/how-to/www-redirect/
Redirecting www to domain apex · Cloudflare Pages docs
In this guide, you will learn how to redirect the www subdomain to your apex domain (example.com). This is a common question and can be achieved by …
simpson
simpsonOP15mo ago
Tried that and it still doesn’t work
Chaika
Chaika15mo ago
in what way? What error do you get? For me, your site does redirect, but it redirects to https://yoursite.live/$1/hi What is your dest. url? It should be https://yoursite.live/$1
simpson
simpsonOP15mo ago
Same as before, www.domain.live doesn’t resolve to anything
Chaika
Chaika15mo ago
It's DNS Cache on your end if you are getting that error still could be local dns cache, or by your resolver. You could try switching to Cloudflare's 1.1.1.1 and clearing local dns cache (depends on OS) or wait it out, shouldn't be more then an hour
simpson
simpsonOP15mo ago
Ah ok let me check
Chaika
Chaika15mo ago
What's your dest. URL in your page rule though? Even once you get that cleared, it looks like your page rule is misconfigured
simpson
simpsonOP15mo ago
In bulk redirects this is what I have, following that article Source: www.domain.live/ Dest: https://domain.live/$1
Chaika
Chaika15mo ago
If you're using Bulk Redirects, you want to follow the screenshot shown in that guide:
Chaika
Chaika15mo ago
(the /$1 is unneeded)
simpson
simpsonOP15mo ago
Yep, followed that Tried with and without $1 Let me remove it again
Chaika
Chaika15mo ago
The DNS Resolution error isn't related to the $1, that was a diff issue Now it's just that the $1 is there, and redirects go to https://www.yoursite.live/hi -> https://yoursite.live/$1/hi that looks better
simpson
simpsonOP15mo ago
Ah there we go, thanks!
Want results from more Discord servers?
Add your server