Domain Redirecton

I own two different domains. I want one of them to redirect to the other one, using Page Rules. I want, that the domain path is being kept and all subdomains, no matter if they exist (wildcard?) redirect to the other domain. Example: 262.domain.net —> domain.com domain.net/test —> domain.com/test 827.domain.net/web —> domain.com/web I included screenshots of what I tried.
17 Replies
Chaika
Chaika17mo ago
Change your page rule forwarding url to https://$1unintendedgames.com/$2
melvin0776
melvin0776OP17mo ago
Thanks for your advise. However I now get this message (Error 522). Could you help me fix it?
melvin0776
melvin0776OP17mo ago
Thanks. It works now, expect that the path isn’t kept. Does it have something to do with the checkbox in the image?
Brandon | Cloudflare TSE
Only if your URLs have query strings at the end, they start with ?
melvin0776
melvin0776OP17mo ago
Okay, because if I create a rule like this it will always end with "$1" instead of the path after the /
Chaika
Chaika17mo ago
placeholders don't work with redirect rules
Brandon | Cloudflare TSE
news to me, i've been using it for a while now without problems
Chaika
Chaika17mo ago
Are you sure you weren't using Page rules? In Page rules they're fully supported, Dynamic Redirect Rules are based on ruleset engine
melvin0776
melvin0776OP17mo ago
I checked, and I used redirecton rules
Brandon | Cloudflare TSE
Seems kind of weird for Page Rules to support it but not Redirect Rules, considering Page Rules is allegedly going away in the future.
Chaika
Chaika17mo ago
Sure, if you want to use Redirect Rules instead of Page rules, you can, the expression is a bit more complex though You can just do match all incoming requests, and use "Type: Dynamic" and "Expression":
concat("https://", substring(http.host, 0, -19), "unintended.games", http.request.uri.path)
// If you're wondering why -19, it's the char count of your domain
concat("https://", substring(http.host, 0, -19), "unintended.games", http.request.uri.path)
// If you're wondering why -19, it's the char count of your domain
(This would work for subdomains as well) 100%, Redirect Rules, based on Ruleset Engine, do have regex_replace, with similar usage as Page rules, but it's Biz or above I mean Redirect Rules are way more flexible, but also way more complex btw make sure you're creating these page rules/dynamic redirect rules in the right cloudflare website. They should be created in unintendedgames.com, not unintended.games within CF That error indicates the request didn't match anything, and it fell through to trying to contact the non-existent origin
melvin0776
melvin0776OP17mo ago
The subdomain path is being kept. I made sure that its the right domain.
Chaika
Chaika17mo ago
you don't want it to keep the subdomain? ex: it currently does https://test.unintendedgames.com/hi => https://test.unintended.games/hi but you want it to do: https://test.unintendedgames.com/hi => https://unintended.games/hi
melvin0776
melvin0776OP17mo ago
Yes, your second example resembles how I wanted it to function.
Chaika
Chaika17mo ago
Ah ok! Yea opps, I see you said that above now as well, I'm just blind. That makes it much simpler then, use this expression:
concat("https://unintended.games", http.request.uri.path)
concat("https://unintended.games", http.request.uri.path)
(Make sure you removed the page rule as well that you created, if you haven't already, or else it'll conflict)
melvin0776
melvin0776OP17mo ago
It worked now. Thank you for helping me with my issue.

Did you find this page helpful?