# dev servers irule

**URL:** <https://community.f5.com/t/dev-servers-irule/35827>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [December 17, 2012, 8:39pm UTC](https://community.f5.com/t/dev-servers-irule/35827 "2012-12-17T20:39:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![F5Hopper\_28651](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@F5Hopper\_28651](https://community.f5.com/u/F5Hopper_28651)\
**Post date:** [December 17, 2012, 8:39pm UTC](https://community.f5.com/t/dev-servers-irule/35827/1 "2012-12-17T20:39:12Z")

</div>

hey guys,

not sure how to do this one, I have

[dev01.www.etc.com](http://dev01.www.etc.com), [dev02.www.etc.com](http://dev02.www.etc.com), through [dev20.www.etc.com](http://dev20.www.etc.com)

I also have

[dev01.app.etc.com](http://dev01.app.etc.com) through [dev20.app.etc.com](http://dev20.app.etc.com).

I want to make an irule that forwards a URI from **www** to **app**.

when HTTP\_REQUEST {

if { [string tolower [HTTP::uri]] eq “/production/webservice.asmx” } {

HTTP::redirect “[http://dev16.app.etc.com/webservice.asmx](http://dev16.api.800loanmart.com/loanmartwebservice.asmx)”

}

}

I have this on the dev--.www.etc.com VS, I have one VS for all DEV01-20 and use an irule for node redirect based on what DEV they are calling. but as you see it is only forwarding to dev16.

if it hits **dev05.www** I wanted it to forward to the **dev05.app**

---

<div class="post-metadata">

**Author:** ![What\_Lies\_Bene1](https://avatars.discourse-cdn.com/v4/letter/w/59ef9b/32.png) [@What\_Lies\_Bene1](https://community.f5.com/u/What_Lies_Bene1)\
**Post date:** [December 17, 2012, 9:06pm UTC](https://community.f5.com/t/dev-servers-irule/35827/2 "2012-12-17T21:06:42Z")

</div>

OK, I’m no expert and haven’t used findstr much or had to use variables with redirect but here’s my first attempt. The idea is to check for a request containing www, pull out the server number and redirect to the correct app domain/server;

```tcl
when HTTP_REQUEST {
 if { [string tolower [HTTP::host]] contains ".www." } {
  set devserverid [findstr [HTTP::host] "dev" 0 "."]
  log local0. "Found $devserverid in HTTP host"
  HTTP::redirect "http://dev" + "$devsererid" + ".app.etc.com[[http:uri]]"
  }
}

```

---

<div class="post-metadata">

**Author:** ![F5Hopper\_28651](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@F5Hopper\_28651](https://community.f5.com/u/F5Hopper_28651)\
**Post date:** [December 18, 2012, 6:10pm UTC](https://community.f5.com/t/dev-servers-irule/35827/3 "2012-12-18T18:10:51Z")

</div>

Nice I tweeked it a bit, but the core was solid.

when HTTP\_REQUEST {

if { ([string tolower [HTTP::host]] contains “.www.” )

and ([string tolower [HTTP::uri]] eq “/webapiproduction/webservice.asmx”) } {

set devserverid [findstr [HTTP::host] “dev” 0 “.”]

HTTP::redirect “http://$devserverid.app.etc.com/webservice.asmx”

}

}

This works for all Dev01-20, listening for www and the /webapiproduction/webservice.asmx then sending them to [dev01-20.app.etc.com/webservice.asmx](http://dev01-20.app.etc.com/webservice.asmx)

Thanks for all the help

Ryan

---

<div class="post-metadata">

**Author:** ![F5Hopper\_28651](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@F5Hopper\_28651](https://community.f5.com/u/F5Hopper_28651)\
**Post date:** [December 18, 2012, 6:16pm UTC](https://community.f5.com/t/dev-servers-irule/35827/4 "2012-12-18T18:16:16Z")

</div>

code -

```tcl
when HTTP_REQUEST {
 if { ([string tolower [HTTP::host]] contains ".www." )
and ([string tolower [HTTP::uri]] eq "/webapiproduction/webservice.asmx") } {
  set devserverid [findstr [HTTP::host] "dev" 0 "."]
  HTTP::redirect "http://$devserverid.app.etc.com/webservice.asmx"
  }
}

```

---

<div class="post-metadata">

**Author:** ![What\_Lies\_Bene1](https://avatars.discourse-cdn.com/v4/letter/w/59ef9b/32.png) [@What\_Lies\_Bene1](https://community.f5.com/u/What_Lies_Bene1)\
**Post date:** [December 18, 2012, 6:21pm UTC](https://community.f5.com/t/dev-servers-irule/35827/5 "2012-12-18T18:21:21Z")

</div>

Good stuff, you’re welcome and thanks for posting back.
