iRule redirect HTTPS to different VS

Looking for a iRule that forwards different request to different vip example:

https://sub1.domain.com forward to vs1

https://sub2.domain.com forward to vs2

http://sub3.domain.com forward to vs3

Thanks

when HTTP_REQUEST {
switch -- "[SSL::mode]-[HTTP::host]" {
  1-sub1 .domain.com { [virtual vs1] }
  1-sub2.domain.com { [virtual vs2] }
  0-sub3.domain.com { [virtual vs3] }
}
}

A few points - maybe think about using ltm policies for this kind of routing.

More importantly, how do you expect to receive http and https traffic on the same virtual server?

}

for http request I will use VS:80 and with iRule that changes http to https

when HTTP_REQUEST {

HTTP::redirect https://[getfield [HTTP::host] “:” 1][HTTP::uri]

}