# iRule redirect HTTPS to different VS

**URL:** <https://community.f5.com/t/irule-redirect-https-to-different-vs/56011>\
**Category:** Technical Forums\
**Tags:** irules, big-ip-access-policy-manager-apm, application-delivery\
**Created:** [November 4, 2019, 10:58am UTC](https://community.f5.com/t/irule-redirect-https-to-different-vs/56011 "2019-11-04T10:58:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![R\_Niznik](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@R\_Niznik](https://community.f5.com/u/R_Niznik)\
**Post date:** [November 4, 2019, 10:58am UTC](https://community.f5.com/t/irule-redirect-https-to-different-vs/56011/1 "2019-11-04T10:58:59Z")

</div>

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

[https://sub1.domain.com](https://sub1.domain.com) forward to vs1

[https://sub2.domain.com](https://sub2.domain.com) forward to vs2

[http://sub3.domain.com](http://sub3.domain.com) forward to vs3

Thanks

---

<div class="post-metadata">

**Author:** ![PeteWhite](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/petewhite/32/33768_2.png) [@PeteWhite](https://community.f5.com/u/PeteWhite)\
**Post date:** [November 4, 2019, 2:54pm UTC](https://community.f5.com/t/irule-redirect-https-to-different-vs/56011/2 "2019-11-04T14:54:48Z")

</div>

```tcl
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?

}

---

<div class="post-metadata">

**Author:** ![R\_Niznik](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@R\_Niznik](https://community.f5.com/u/R_Niznik)\
**Post date:** [November 4, 2019, 3:23pm UTC](https://community.f5.com/t/irule-redirect-https-to-different-vs/56011/3 "2019-11-04T15:23:22Z")

</div>

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]

}
