Forum Discussion
Switch option always matches on default
Hello everybody. I have one question which probably for some people should be something simple, but I have spent a few days on a lab environment and studying a lot, with no succesfull results. I need to do a previous check to send a path which starts with /pf to a pool, but always goes to the default pool. The first or second part is working, but I can't make it work together.
This is the iRule:
when HTTP_REQUEST
{
if {[string tolower [HTTP::uri]] starts_with "/pf" }
{
HTTP::uri [string map {"/pf/" "/PF/"} [HTTP::uri]]
pool Pool_apache_lab
}
switch -glob [string tolower [HTTP::path]] {
"default" { HTTP::respond 200 content {
Default switch
}
}
}
}
Mandatory is not to touch "switch -global", but for the first match, I can use a "global", "if", "else if" or anything you suggest.
Thanks in advance.
- Leonardo_SouzaCirrocumulus
I don't understand your problem. If you only have the default option in the switch, it always triggers that.
Can you explain a little bit more the problem?
- Stanislas_Piro2Cumulonimbus
Hi,
I think you want to include the first condition in the switch command:
when HTTP_REQUEST { switch -glob -- [string tolower [HTTP::path]] { "/pf*" { HTTP::uri [string map {"/pf/" "/PF/"} [HTTP::uri]] pool Pool_apache_lab } "default" { HTTP::respond 200 content {Default switch} } } }
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