Redirect based on incoming port?

I’m trying to accomplish the following with an irule, without much luck. Can anyone help me achieve the following:

Thanks, SH

Can you provide you iRule ? It will be easier to edit, if you already have something in place.

This is a rough template for you to tailor to your requirements:

when CLIENT_ACCEPTED {
    if { [string tolower [HTTP::uri]] starts_with "/sample" } {
    switch [TCP::local_port clientside] {
    8083 -
    444 { HTTP::respond 301 Location "https://hostname.domain.com:7151" }
    8084 -
    446 { HTTP::respond 301 Location "http://hostname.domain.com:7152" }
    8085 - 
    447 { HTTP::respond 301 Location "http://hostname.domain.com:7153" }
    default { discard } 
    }
  }
}