Forum Discussion
Execute two If condition in one iRule -- sorry page
I am new to iRule and need help in creating a sorry page
Here is condition
I have two pool english and french. When the nodes in the English pool are offline then redirect to URL (example google.com). When the nodes in French pool are offline then redirect to URL (example yahoo.com). I don’t want to redirect both
Here is iRule
when HTTP_REQUEST {
if {[active_members english] == 0} {
HTTP::redirect "http://google.com"
}
if {[active_members french] == 0 } {
HTTP::redirect "http://yahoo.com/"
}
}
Here is the problem
If the English pool is offline then the request get redirected to google.com, but it also redirect the request to French to google.com.
Same is true other way around. If French pool is offline then it is redirected to yahoo.com, but the English pool also get redirected to yahoo.com
I want to redirect only if the condition is true for which-ever pool. E.g English or French.
Please help
3 Replies
- Kevin_Stewart
Employee
Quick question. How are you directing user requests to the English or French pools? The Accept-Language header? A URI? - computerli
Altostratus
I am using accept language ($al contains "fr") - Kevin_Stewart
Employee
I think you need to perform the active_members conditional within the scope of the requested language. Something like this perhaps:when HTTP_REQUEST { switch [string tolower [HTTP::header Accept-Language]] { "en" { if { [active_members english] == 0 } { HTTP::redirect "http://google.com" } else { pool english } } "fr" { if { [active_members french] == 0 } { HTTP::redirect "http://yahoo.com" } else { pool french } } default { do something else... } } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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