Failing to redirect a subdomain to another page (within the same hostname)

Hi, I have a domain whose DNS is controlled by cloudflare and the Cloudflare Pages is serving a static site from Github repo.
Now I am trying to redirect a specific subdomain ( to a specific page ( or

I first read:
Essentially, I created Rules → Redirect Rules. Where I specified URI Full Path and gave the target address. See

I also added a subdomain to my DNS. I tried both A record with (proxied) and CNAME with the main domain address (proxied). Both didnt work.

In all cases, going to a subdomain ( on a browser gave Error code 522

Is there any fix?

You were so very close to having it match – You just need a / at the end since path is never empty, ex
I would recommend using a more exact match though, for example your match on URI Full would break if there was any query parameters.
Instead, you could do
Hostname eq
Path eq /

Less brittle of a match.
If you wanted it to redirect any page on, ex even, then you could just remove/not add the URI Path check, and just match by hostname alone.

Thank you and it works!
Is there a way to keep the URL from changing? After the redirect, I would like the subdomain URL to stay, as if the content is served from that.

If that’s not possible, is there any way to do so using cloudflare and static site?

You could add as another Pages Custom Domain, and then use a Transform Rule → Rewrite URL (Rewrite URL rules · Cloudflare Rules docs) like this:

(Make sure to remove the redirect rule!)
This isn’t always a safe thing to do due to relative paths, CORS and such, but in your case it looks like it might just work


This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.