Forum Discussion
COMMS-CORE_1795
Nimbostratus
Feb 01, 20162 actions in the same rule: redirect + load balance
Hi all,
I need to make an iRule whose behaviour is:
1.- When the web starts with "/a/b" redirect to "/b" AND balance to the pool POOL_x.x.x.x_8090
2.- When the web starts with "/a/" redir...
Kai_Wilke
MVP
Feb 01, 2016Hi Comms-Core,
you can chain as many conditions in a single
[if] command by using elseif or else conditions. The most restictive conditions are evaluated first followed by the least most restictive conditions.
Based on your provided requirements, the
[if] command would look like this.
when HTTP_REQUEST {
Format the URI tolower to negate the CASE while comparing the requested URIs
set low_uri [string tolower [HTTP::uri]]
Evalute the contition step-by-step. Starting with the most restrictive condition...
if { $low_uri starts_with "/a/b" } then {
HTTP::redirect "http://[HTTP::host]/b"
} elseif { $low_uri starts_with "/a" } then {
HTTP::redirect "http://[HTTP::host]/"
} elseif { $low_uri starts_with "/b" } then {
pool POOL_1.1.1.1_8090
} else {
The else condition will catch everything else (e.g. /*)
pool POOL_2.2.2.2_8090
}
}
Cheers, Kai
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