# irule help for uri redirection

**URL:** <https://community.f5.com/t/irule-help-for-uri-redirection/41067>\
**Category:** Technical Forums\
**Created:** [November 11, 2015, 7:45pm UTC](https://community.f5.com/t/irule-help-for-uri-redirection/41067 "2015-11-11T19:45:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amalhotra\_6478](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@amalhotra\_6478](https://community.f5.com/u/amalhotra_6478)\
**Post date:** [November 11, 2015, 7:45pm UTC](https://community.f5.com/t/irule-help-for-uri-redirection/41067/1 "2015-11-11T19:45:08Z")

</div>

Hello Need some help on building an irule, very new to irules.

[http://soft.abc.com/expo](http://soft.abc.com/expo) - would redirect the request to Expo server on a certain port (say 2000) [http://soft.abc.com/granite](http://soft.abc.com/granite) - would redirect the request to Granite server on a certain port (say 4000) [http://soft.abc.com/csg](http://soft.abc.com/csg) - would redirect the request to CSG server on a certain port (say 5000)

I understand the basic that I shall add node to a pool with certain port as a member and then use Http uri method in irule for redirection.

Thanks!

---

<div class="post-metadata">

**Author:** ![amalhotra\_6478](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@amalhotra\_6478](https://community.f5.com/u/amalhotra_6478)\
**Post date:** [November 11, 2015, 8:04pm UTC](https://community.f5.com/t/irule-help-for-uri-redirection/41067/2 "2015-11-11T20:04:28Z")

</div>

Here is what I build up and looking how to combine and if any correction to it Appreciate help if someone can look into it Thanks!

when HTTP\_REQUEST { if { [HTTP::uri] contains “/expo” } { pool expo\_pool port 2000 } else { pool all\_pool } }

when HTTP\_REQUEST { if { [HTTP::uri] contains “/granite” } { pool granite\_pool port 4000 } else { pool all\_pool } }

---

<div class="post-metadata">

**Author:** ![amalhotra\_6478](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@amalhotra\_6478](https://community.f5.com/u/amalhotra_6478)\
**Post date:** [November 11, 2015, 9:16pm UTC](https://community.f5.com/t/irule-help-for-uri-redirection/41067/3 "2015-11-11T21:16:01Z")

</div>

This is second one I build so far Please advise if any corrections or better options on it.

when HTTP\_REQUEST {

if {[HTTP::uri] contains “/expo” } { pool granite\_pool port 2000 }

if {[HTTP::uri] contains “/granite” } { pool granite\_pool port 4000 }

if {[HTTP::uri] contains “/csg” } { pool csg\_pool port 5000 }

}

---

<div class="post-metadata">

**Author:** ![amalhotra\_6478](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@amalhotra\_6478](https://community.f5.com/u/amalhotra_6478)\
**Post date:** [November 12, 2015, 1:42am UTC](https://community.f5.com/t/irule-help-for-uri-redirection/41067/4 "2015-11-12T01:42:28Z")

</div>

Checked some irules on Dev Centeral seems port will be required with Node, if I mention Pool port is not required as pool will be configured with a member listening on port. I think this shall work, will be great if someone has done a similar request earlier. Getting familiar with irules little bit.

when HTTP\_REQUEST { if { [HTTP::uri] contains “/expo” } { pool pool\_expo }

if { [HTTP::uri] contains “/granite” } { pool pool\_granite }

if { [HTTP::uri] contains “/csg” } { pool pool\_csg

} else { pool default\_pool }

}
