# Irule - Load Balance

**URL:** <https://community.f5.com/t/irule-load-balance/7805>\
**Category:** Technical Forums\
**Tags:** irules, devops, ltm, application-delivery\
**Created:** [January 6, 2017, 8:10pm UTC](https://community.f5.com/t/irule-load-balance/7805 "2017-01-06T20:10:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![F51982\_110427](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@F51982\_110427](https://community.f5.com/u/F51982_110427)\
**Post date:** [January 6, 2017, 8:10pm UTC](https://community.f5.com/t/irule-load-balance/7805/1 "2017-01-06T20:10:25Z")

</div>

Question on redirects and load balancing the redirect based on IP Address.

Is this possible? is my first question.

Here is an Example -

Existing site is

[msoft.com/login/grumpy](http://msoft.com/login/grumpy)

New Site is going to be redirected and users would go to

[microsoft.com/happydays](http://microsoft.com/happydays)

Is it possible to issue a redirect of the existing site and load balance it to it’s new servers under [microsoft.com/happydays](http://microsoft.com/happydays)

I have attempted to issue a redirect and load balance via an if/elseif statement however the data does not appear to go beyond the Http::respond -

```tcl
ltm data-group datagroupvariable {
records {
    /happydays {
       data /login/grumpy
    }
}

set variablewebsite [string tolower [HTTP::uri]]

  if { ([class match $variablewebsite equals /datagroupvariable]) } {

     HTTP::respond 301 location "https://[HTTP::host][class lookup $variablewebsite /datagroupvariable]"
     } elseif { [class match [IP::client_addr] equals 192.168.1.0/24] } {
          pool NewServerPool
     } else {
          reject
     }
  }

```

I can get a respond page, but while including the class match of client IP, I do not get a load balanced page. I get nothing instead.

Any Ideas?

---

<div class="post-metadata">

**Author:** ![cjbarr1234](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cjbarr1234](https://community.f5.com/u/cjbarr1234)\
**Post date:** [January 6, 2017, 8:16pm UTC](https://community.f5.com/t/irule-load-balance/7805/2 "2017-01-06T20:16:07Z")

</div>

What I’ve done in the past on this is in order, put in the redirect, and then replace the host header with the new site. The problem that I had though, was redirect of two different site certificates since they did not share the same TLD. The irule to 302, redirect to the new VS, but then also at the end replace the host header with “new site”.

Does that make sense?

---

<div class="post-metadata">

**Author:** ![Vijay\_E](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vijay\_E](https://community.f5.com/u/Vijay_E)\
**Post date:** [January 7, 2017, 12:44am UTC](https://community.f5.com/t/irule-load-balance/7805/3 "2017-01-07T00:44:22Z")

</div>

```tcl
if { ([class match $variablewebsite equals /datagroupvariable]) } {

```

I see “/datagroupvariable” as the data group name. Is the “/” a typo ?
