Forum Discussion

Robert_47833's avatar
Icon for Altostratus rankAltostratus
Jun 03, 2011

switch -glob to match two or more than two conditions

Hi,I wanna to achieve this ,use switch -glob instead of if/else chain



if { [[TCP::local_port clientside] != 443] && [[HTTP::uri] starts_with "/mobile/auth"] }




HTTP::redirect "https://[getfield [HTTP::host] ":" 1]/[HTTP::uri]"


log local0. "here i am 1 [HTTP::uri]"








persist none


SSL::disable serverside




log local0. "here i am 2 [HTTP::uri]" }




but how to achieve this cause we need to match 2 conditions here.

3 Replies

  • A switch will only allow you to check one string to see if it matches specific cases. You can't check the TCP::local_port value and the URI. So what you have there is as good as it gets.



  • Colin_Walker_12's avatar
    Historic F5 Account
    Aaron's point is a good one. The switch command, while efficient and wonderful (I'm a fan, what can I say?) does have limitations. When trying to compare multiple pieces of information you're going to be nesting switches quickly and that can get messy. Ifs can be better in these cases if you're dealing with small numbers of matches (like one).