Forum Discussion
Michael_Hunzike
Nimbostratus
Mar 11, 2005Problem with elseif
Okay, this is driving me nuts...I'm trying to get a simple nested if statement working and it's not....
This works:
when HTTP_REQUEST
{
if {[HTTP::host] equals "dev.domain.com" }
{
if { [HTTP::uri] starts_with "/wps/portal" }
{
log "matched /wps/portal"
pool dev_domain_portal
}
else
{
log "no match on [HTTP::uri] fallthrough sending to portal home"
HTTP::redirect "http://dev.domain.com/wps/portal/Home"
}
}
}
When I add an elseif so that it looks like this:
when HTTP_REQUEST
{
if {[HTTP::host] equals "dev.domain.com" }
{
if { [HTTP::uri] starts_with "/wps/portal" }
{
log "matched /wps/portal"
pool dev_domain_portal
}
else
{
log "no match on [HTTP::uri] fallthrough sending to portal home"
HTTP::redirect "http://dev.domain.com/wps/portal/Home"
}
}
elseif { [HTTP:host equals "dev.newdomain.com" }
{
discard
}
}
I get this error:
line 16: [undefined procedure: elseif] [elseif { [HTTP:host equals "dev.newdomain.com"}
{
discard
}]
7 Replies
Sort By
- rapmaster_c_127Historic F5 AccountWe're a little overly sensitive to whitespace. Also your HTTP::host line is wrong. Try this:
rule rastak { when HTTP_REQUEST { if {[HTTP::host] equals "dev.domain.com" } { if { [HTTP::uri] starts_with "/wps/portal" } { log "matched /wps/portal" pool dev_domain_portal } else { log "no match on [HTTP::uri] fallthrough sending to portal home" HTTP::redirect "http://dev.domain.com/wps/portal/Home" } } elseif { [HTTP::host] equals "dev.newdomain.com" } { discard } } }
- Michael_Hunzike
Nimbostratus
First thanks to both of you for responding. - rapmaster_c_127Historic F5 AccountHi,
- rapmaster_c_127Historic F5 AccountOne quick question about your cutting and pasting my rule into the UI: are you making sure you omit the "rule rastak" line and closing brace? I pasted this from my bigip.conf. Putting rules into the UI requires that you omit the rule declarators.
- Michael_Hunzike
Nimbostratus
Posted By rapmaster_c on 3/11/2005 9:54:00 AM - Michael_Hunzike
Nimbostratus
Okay, it's working. elseif after the 2nd to last } and on the same line with one space works. - unRuleY_95363Historic F5 Account
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