# iRule to Remove a part of uri and forward to a pool

**URL:** <https://community.f5.com/t/irule-to-remove-a-part-of-uri-and-forward-to-a-pool/46201>\
**Category:** Technical Forums\
**Tags:** iapps, irules, application-delivery\
**Created:** [December 4, 2018, 12:55pm UTC](https://community.f5.com/t/irule-to-remove-a-part-of-uri-and-forward-to-a-pool/46201 "2018-12-04T12:55:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Mehra](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@Aditya\_Mehra](https://community.f5.com/u/Aditya_Mehra)\
**Post date:** [December 4, 2018, 12:55pm UTC](https://community.f5.com/t/irule-to-remove-a-part-of-uri-and-forward-to-a-pool/46201/1 "2018-12-04T12:55:24Z")

</div>

Hi,

i am working on an iRule to Remove a part of uri and forward to a pool.

Eg:

**xxx/yyy** /abc/def should go to a pool 1 as

i want to remove **xxx/yyy**

Will the below work?

when HTTP\_REQUEST {

set var1 “ **xxx/yyy** ”

if {([HTTP::uri] contains $var1) } {

set newUri [string map -nocase [list $var1 “”] [HTTP::uri]]

set HTTP::uri ${newUri}

pool Pool\_1

}

---

<div class="post-metadata">

**Author:** ![Lee\_Sutcliffe](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@Lee\_Sutcliffe](https://community.f5.com/u/Lee_Sutcliffe)\
**Post date:** [December 4, 2018, 1:53pm UTC](https://community.f5.com/t/irule-to-remove-a-part-of-uri-and-forward-to-a-pool/46201/2 "2018-12-04T13:53:59Z")

</div>

Hi Aditya,

You were almost there, you don’t need to set

```tcl
HTTP::uri

```

and the final

```tcl
}

```

to close the HTTP\_REQUEST event was missing. I’ve also remove some necessary parenthesis and the was no advantage in setting

```tcl
$newUri

```

other than perhaps readability.

```tcl
when HTTP_REQUEST { 
    set var1 "xxx/yyy" 
    if {[HTTP::uri] contains $var1} {
        HTTP::uri [string map -nocase [list $var1 ""] [HTTP::uri]]
        pool Pool_1
    }
}

```
