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
Change your page rule forwarding url to
https://$1unintendedgames.com/$2
Thanks for your advise. However I now get this message (Error 522). Could you help me fix it?
Try this with a Redirect Rule instead:
https://dash.cloudflare.com/?to=/:account/:zone/rules/redirect-rules/new
Thanks. It works now, expect that the path isn’t kept. Does it have something to do with the checkbox in the image?
Only if your URLs have query strings at the end, they start with
?
Okay, because if I create a rule like this it will always end with "$1" instead of the path after the /
placeholders don't work with redirect rules
news to me, i've been using it for a while now without problems
Are you sure you weren't using Page rules?
In Page rules they're fully supported, Dynamic Redirect Rules are based on ruleset engine
I checked, and I used redirecton rules
Seems kind of weird for Page Rules to support it but not Redirect Rules, considering Page Rules is allegedly going away in the future.
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":
(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 originThe subdomain path is being kept.
I made sure that its the right domain.
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
Yes, your second example resembles how I wanted it to function.
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:
(Make sure you removed the page rule as well that you created, if you haven't already, or else it'll conflict)
It worked now. Thank you for helping me with my issue.