Forum Discussion
sandy16
Altostratus
Oct 06, 2014irule for URI based redirection to separate Pools
Hi, I am new to irules. Need help in writing an irule that does a simple URI re-direction to seperate Pools with NO default Pool on the VS and the F5 returns a default-http page guiding to the user t...
cjunior
Nacreous
Oct 07, 2014You can find a good documentation of iRule events tips and tricks in this link: https://devcentral.f5.com/articles/irules-101-04-switch
I will try to be clear, here we go:
This event triggers in http request
when HTTP_REQUEST {
this will store the first http path segment in lower case
so, we'll define the request traffic direction as needed
example:
request for url: http://mywebservice.com/DEV/service
[HTTP::host] ==> mywebservice.com (not used, just to understand)
[HTTP::path] ==> /DEV/service
[split [HTTP::path] "/"] ==> [split /DEV/service "/"] ==> { DEV service}
[lindex { DEV service} 1] ==> DEV
[string tolower {DEV}] ==> dev (this is useful when web service is case insensitive (windows eg))
set path ==> stores the value "dev"
set path [string tolower [lindex [split [HTTP::path] "/"] 1]]
this will verify the value stored in path variable
switch -glob $path {
case value is "dev", request goes to the pool-dev
"dev" { pool pool-dev }
case value is "ct", request goes to the pool-ct
"ct" { pool pool-ct }
case value is "uat", request goes to the pool-uat
"uat" { pool pool-uat }
otherwise, show the help page
default {
here we will write the response content page
HTTP::respond 200 content "`Available resource options````Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects