# rewrite iRule

**URL:** <https://community.f5.com/t/rewrite-irule/55317>\
**Category:** Technical Forums\
**Tags:** tmos, big-ip-access-policy-manager-apm, security, ltm, application-delivery, citrix\
**Created:** [May 14, 2015, 8:24am UTC](https://community.f5.com/t/rewrite-irule/55317 "2015-05-14T08:24:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antony2015](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@Antony2015](https://community.f5.com/u/Antony2015)\
**Post date:** [May 14, 2015, 8:24am UTC](https://community.f5.com/t/rewrite-irule/55317/1 "2015-05-14T08:24:09Z")

</div>

How to write the below iRule if I want to use the two events together ?

event&Condition:

when CLIENT\_ACCEPTED {

```tcl
Client IP:[IP::client_addr] equals 10.0.0.0/8

```

} when HTTP\_REQUEST { if { [string tolower [HTTP::header User-Agent]] contains “/Firefox” or “/Chrome” or “/Opera” or “/safari” }

Action

The action is to rewrite the URI.

-reqUrlFrom “[https://www.f5.com/citrix/wwl\_prodweb/](https://www.f5.com/citrix/wwl_prodweb/)” -reqUrlInto “[https://www.f5.com/citrix/wwl\_prodwebExplicit/](https://www.f5.com/citrix/wwl_prodwebExplicit/)”

Any help would be highly appreciated !

---

<div class="post-metadata">

**Author:** ![nitass](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/nitass/32/2270_2.png) [@nitass](https://community.f5.com/u/nitass)\
**Post date:** [May 14, 2015, 8:41am UTC](https://community.f5.com/t/rewrite-irule/55317/2 "2015-05-14T08:41:33Z")

</div>

is it something like this?

```tcl
when HTTP_REQUEST {
  if { [IP::addr [IP::client_addr] equals 10.0.0.0/8] } {
    if { [HTTP::uri] equals "/citrix/wwl_prodweb/" } {
      switch -glob [HTTP::header "User-Agent"] {
        "*Firefox*" -
        "*Chrome*" -
        "*Opera*" -
        "*safari*" {
          HTTP::redirect "http://[HTTP::host]/citrix/wwl_prodwebExplicit/"
        }
        default {
           User-Agent is not FF, Chrome, Opera, safari
           Do something
        }
      }
    } else {
       URI is not equal to /citrix/wwl_prodweb/
       Do something
    }
  } else {
     IP is not in 10.0.0.0/8 subnet
     Do something
  }
}

```
