Forum Discussion
If / else not working
BigIP v11.5.1
Attempting to write an irule that redirects to different pools based on URI - super basic, but for some reason when adding the rule into the LTM console, it errors out when using ELSE. If I update it to use ELSEIF then it works. However, the logic as it is below is how I would like it, only if it sees the URI of /loyaltyapi does it redirect, otherwise it goes to the default pool for the Virtual Server.
Here is my iRule
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] starts_with "/loyaltyapi" } {
pool rcv100crw-pool-http
}
else {
pool rcv100cwb-pool-http
}
}
when I put that into the LTM, I get the following errors:
01070151:3: Rule [/Common/api_redirect_http] error: /Common/api_redirect_http:2: error: [undefined procedure: &160][ ] /Common/api_redirect_http:5: error: [undefined procedure: else][else { pool rcv100cwb-pool-http }]
Any guidance would be greatly appreciated.
- nathe
Cirrocumulus
Justin, if you're using the default pool why not remove the else statement altogether?
The irule does look ok to be honest, but not at my bigip to confirm 100%.
N
- Stanislas_Piro2
Cumulonimbus
Hi,
this kind of error appears when there is issue with missing space between curly brackets or something like that. thy this!
when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with "/loyaltyapi" } { pool rcv100crw-pool-http } else { pool $default_pool } }
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