Forum Discussion
return and HTTP::redirect usage
if {$uri matches_regex "^/(help/)"}
{
HTTP::redirect ]
pool cjj1
return
}
else{
pool cjj2
}
1:don't know the true meaning of return
2:can I use
HTTP::redirect http://[HTTP::HOST][HTTP::uri]
pool cjj1
in this way?
- The_BhattmanNimbostratusHi Jucao,
- hooleylistCirrostratusI'd also replace the regex with a more efficient string command:
- Robert_47833AltostratusHi,Bhattman hoolio
- Robert_47833AltostratusHi,can some one help me ?
- richard_77048NimbostratusThe HTTP::redirect command immediately sends the redirect response to the client. You can't set a pool after issuing this command. You are sending the client back through your loadbalancer on a new request.
- Robert_47833Altostratusthank richard so much
- Colin_Walker_12Historic F5 AccountKeep in mind that return does not exit the iRule, only the event context that it's fired in. This means in an iRule with multiple events, return does not stop the rest of the events from processing. It merely stops the processing of the current event.
- richard_77048NimbostratusColin,
That's really good to know. So, if you wanted to bail on the rule altogether, would something like this work?
when HTTP_REQUEST {
if { some_condition } {
set bail_on_rule "true"
}
}
when HTTP_RESPONSE {
if { $bail_on_rule equals "true" } {
event disable
}
else {
other_stuff
}
}
Do variables live between events in the same rule? Is there an easier (maybe built in) way of doing this?
Richard
edit: lost my psuedo-code on posting
- Colin_Walker_12Historic F5 AccountThere isn't a way to stop the iRule processing as a whole, really. The closest you can come is "event disable all", but that's scoped to the connection as a context. That means that if you fire an event disable (or an event disable all) you're turning off that event for all iRules on that connection, not just the iRule it was fired within.
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