Forum Discussion
Snl
Cirrostratus
Apr 03, 2016Irule issue for if statement error
Hello folks
need help on below , i am getting undefined procedure in line3 and missing script after if error line 2
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/dfg") and !([matchclas...
VernonWells
Employee
Apr 03, 2016It's likely caused by the way the rule is flattened. When I create a rule as follows on 11.5.3, it works fine:
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/dfg") and !([matchclass [IP::remote_addr] equals IP_Range]) } {
HTTP::redirect "https://abc.com"
}
pool ab-Pool
}
Newlines (and semi-colons) are statement delimiters in Tcl, and somewhat counter-intuitively,
if is a command in Tcl, as is pool. Therefore, the if { ... } { ... } is one statements, and the pool ... in another.
Having said that, note that
matchclass is deprecated, as explained here:
You should use
class match, instead.
Moreover, the
pool command at the end is essentially a noop if you assigned that pool to the associated Virtual Server. Assuming this is the only iRule associated with the VS, you should remove the pool command, and if you've not done so already, assign the pool to the VS. It is clearer and more performant.Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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