Redirect Rules

Hello good morning. I have been requested to setup a redirect rule for the following: HTTP or HTTPS - hostredirect.domain.com/* to be redirected to the adjecnt page located at HTTP or HTTPS - hostredirect.sub.domain.com The rule I currently have is doing the following hostredirect.domain.com redirects to hostredirect.domain.com/hostredirect.sub.domain.com Is what I am trying to do above possible to accomplish and if so, how must I fashion this rule in order to work as expected?
8 Replies
Chaika
Chaika16mo ago
What's your exact rule configuration? There's 4 different rules types you could be using to do redirects/rewrites. It sounds like you just didn't put the scheme/protocol for the redirect target, i.e it should be https://hostredirect.sub.domain.com
Sklaar
SklaarOP16mo ago
No description
Chaika
Chaika16mo ago
yea, qualify it with the protocol https://, https://hostredirect.sub.domain.com, otherwise it assumes it's a relative path That wouldn't keep the existing path btw, was that something you wanted as well?
Sklaar
SklaarOP16mo ago
Yea so if they went to either http://hostredirect.domain.com/anywhere it would send you to http://hostredirect.sub.domain.com/anywhere and the same for HTTPS
Chaika
Chaika16mo ago
Change URL Redirect Type from Static to Dynamic and then the URL/Expression to concat("https://hostredirect.sub.domain.com", http.request.uri.path) That would force all connections to https though, if you have always use https on anyway that wouldn't matter, and you really should be using https for everything in 2023 unless you have some exceptional case otherwise. If you really wanted to keep http://, the easiest way would probably be to create two redirect rules, one matching ssl/https on, another matching it off, and having the protocol in the url target adjusted accordingly
Sklaar
SklaarOP16mo ago
This is great!!! Thank you so much!! This seems to be working as expected. Is there anyway to do this on a non standard port like https://hostredirect.domain.com:8112/anywhere
Chaika
Chaika16mo ago
You would want to preserve the port? It would have to be one of Cloudflare's supported ones: https://developers.cloudflare.com/fundamentals/reference/network-ports/, currently if you tried it on one of those alt ports it should just strip it
Sklaar
SklaarOP16mo ago
Thank you so much for the clarification.. I very much appreciate your assistance. No I just gotta figure out this one port if I can get it changed unless there is another way.

Did you find this page helpful?