Forum Discussion
smp_86112
Cirrostratus
Jun 24, 2010Optimizing If statement conditions
I see this examples like this all over the place:
when HTTP_REQUEST {
if { [HTTP::host] equals "www.myhost.com" and [HTTP::uri] equals "/myuri" } {
HTTP::redirect https://[HTTP::host][HTTP::...
The_Bhattman
Nimbostratus
Jun 24, 2010Hi SMP,
It certainly would seem efficient. You can't do this now within iRules because they are 2 seperate functions in a single if conditional statement. Perhaps another method would be setting the entire URL into a variable then doing the IF comparison.
i.E.
when HTTP_REQUEST {
set url [HTTP::host][HTTP::uri]
if {$::url equals "www.something.com/blah"} {
.
.
.
do something
.
.
.
}
}
Doesn't seem efficient because you end up creating a variable, but it looks cleaner on the IF statement, at least to me.
I hope this helps
Bhattman
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