# logic based on Virtual Server

**URL:** <https://community.f5.com/t/logic-based-on-virtual-server/31742>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [November 27, 2007, 6:42pm UTC](https://community.f5.com/t/logic-based-on-virtual-server/31742 "2007-11-27T18:42:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_69413](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@Brian\_69413](https://community.f5.com/u/Brian_69413)\
**Post date:** [November 27, 2007, 6:42pm UTC](https://community.f5.com/t/logic-based-on-virtual-server/31742/1 "2007-11-27T18:42:57Z")

</div>

I have an iRule that is applied to multiple Virtual Servers but should take different actions depending on which one triggers the rule. Is there a way to to perform logic based on Virtual Server?

Thanks!

---

<div class="post-metadata">

**Author:** ![JRahm](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/jrahm/32/3327_2.png) [@JRahm](https://community.f5.com/u/JRahm)\
**Post date:** [November 27, 2007, 6:52pm UTC](https://community.f5.com/t/logic-based-on-virtual-server/31742/2 "2007-11-27T18:52:02Z")

</div>

You could use a switch:

```tcl
switch [virtual name] {
      "vip1" {
        do stuff here ....
      }
      "vip2" -
      "vip3" {
        do different stuff here ....
      }"
      default {
        do default stuff here ....
      }
}

```

---

<div class="post-metadata">

**Author:** ![Brian\_69413](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@Brian\_69413](https://community.f5.com/u/Brian_69413)\
**Post date:** [November 27, 2007, 6:58pm UTC](https://community.f5.com/t/logic-based-on-virtual-server/31742/3 "2007-11-27T18:58:01Z")

</div>

Perfect, so [virtual name] contains the name of the Virtual Server being used?

---

<div class="post-metadata">

**Author:** ![JRahm](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/jrahm/32/3327_2.png) [@JRahm](https://community.f5.com/u/JRahm)\
**Post date:** [November 27, 2007, 7:10pm UTC](https://community.f5.com/t/logic-based-on-virtual-server/31742/4 "2007-11-27T19:10:21Z")

</div>

Yep…Here’s the wiki page: [Click here](http://devcentral.f5.com/Wiki/default.aspx/iRules/virtual.html)

Note the version specific lanaguage on this command. It looks like you may only want [virtual]

---

<div class="post-metadata">

**Author:** ![Brian\_69413](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@Brian\_69413](https://community.f5.com/u/Brian_69413)\
**Post date:** [November 27, 2007, 7:22pm UTC](https://community.f5.com/t/logic-based-on-virtual-server/31742/5 "2007-11-27T19:22:32Z")

</div>

Thanks!
