URL forwarding for sub.domain with/out port number

I searched and tried different topics here but not working so far (at least for a newbie like me :slight_smile: so any help would be much appreciated. Here’s what I’d like to achieve:

- https://sub.domain.com will be redirected to https://domain.com
- https://sub.domain.com:1234 will not be redirected

Which redirect tool (single, bulk, page rules) should I use and how to?


Cloudflare listens on the ports listed in this doc: Network ports · Cloudflare Fundamentals docs
If you want to ‘listen’ for HTTP/S traffic on a port not listed there, you need to purchase Spectrum. That will allow you to create redirects that a) trigger on all ports, or b) redirects that trigger only on the specific port you list.

Thanks @smarsh and port number 1234 just for example. I researched a bit more and here is the expression to get the redirections as i mentioned earlier with port 8443 for example. Please see if it is correct and thank you:

(http.host eq "sub.domain.com" and not cf.edge.server_port in {8443})

Depends what you want to do, but yes the cf.edge.server_port field can be used to determine whether the redirect triggers, or not. i.e. cf.edge.server_port not in {80 443} will trigger the redirect for requests to ports that arent 80 and 443, for example. You can then augment that with additional fields, such as http.host as you have in your example.

1 Like

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