consolidate multiple irules in to one irule

is possible to consolidate the following irules into one rule ?

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/mtp/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/console/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/mtpadm/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/remote-deploy/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/juddi/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/activeemg/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/console-base/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/debug-views/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/plan-creator/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/monitoring/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/plugin/” } {

drop

}

}

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “/system-database/” } {

drop

}

}

Hi John,

You’ll get a lot more views if you post to the main iRules forum here:

http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/afv/topicsview/aff/5/asg/50/Default.aspx

Yes, you can combine all of those iRules into one using a more efficient switch statement. For details on using switch, you can check this article:

http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/244/Switch-Gone-Wild-Using-Wildcards-with-the-Tcl-switch-command.aspx

and the switch wiki page:

http://devcentral.f5.com/wiki/default.aspx/iRules/switch

when HTTP_REQUEST {

    Check the requested URI, set to lower case with wildcards
   switch -glob [string tolower [HTTP::uri]] {
      "*/mtp/*" -
      "*/console/*" -
      "*/mtpadm/*" -
      "*/remote-deploy/*" -
      "*/juddi/*" -
      "*/activeemg/*" -
      "*/console-base/*" -
      "*/debug-views/*" -
      "*/plan-creator/*" -
      "*/monitoring/*" -
      "*/plugin/*" -
      "*/system-database/*" {
         drop
      }
   }
}

Aaron