# Redirect based on cookie

**URL:** <https://community.f5.com/t/redirect-based-on-cookie/45743>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [July 11, 2007, 3:06pm UTC](https://community.f5.com/t/redirect-based-on-cookie/45743 "2007-07-11T15:06:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlick2](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@mlick2](https://community.f5.com/u/mlick2)\
**Post date:** [July 11, 2007, 3:06pm UTC](https://community.f5.com/t/redirect-based-on-cookie/45743/1 "2007-07-11T15:06:12Z")

</div>

I have the following rule applied and working, but I would like to modify it so that rather than doing a redirect, I would just change the uri to a different directory. I have tried a couple of different methods with no success.

The original request is coming in to [www.foo.com](http://www.foo.com) and the client gets /login.jsp appended from the apache server

when HTTP\_REQUEST {

if { [HTTP::cookie exist “cookie”] }{

scan [HTTP::cookie “cookie”] “%f” cookieval

if { $cookieval \> 5 } {

HTTP::redirect “[http://www.foo.com/sysbusy.htm](http://www.foo.com/sysbusy.htm)”

}

}

}

Thanks in advance,

Matt

---

<div class="post-metadata">

**Author:** ![Colin\_Walker\_12](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Colin\_Walker\_12](https://community.f5.com/u/Colin_Walker_12)\
**Post date:** [July 18, 2007, 6:54pm UTC](https://community.f5.com/t/redirect-based-on-cookie/45743/2 "2007-07-18T18:54:25Z")

</div>

If all you’re looking to do is change the redirect to modify the URI directly before passing on the request, you’d want something like:

```tcl
when HTTP_REQUEST {
  if { [HTTP::cookie exist "cookie"] }{
    scan [HTTP::cookie "cookie"] "%f" cookieval
    if { $cookieval > 5 } {
      HTTP::uri "sysbusy.htm"
    }
  }
}

```

HTH,

Colin
