For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

TNY_122436's avatar
TNY_122436
Icon for Nimbostratus rankNimbostratus
Oct 28, 2013

iRule Help

I'm trying to create a rule that will do redirections base on certain words are contain in the URI, but not sure where to start or what is going on as only one argument is working (test.123.tree) and the two other isn't working. Is there something wrong with my code?Here is the scenerio:

 

When a end user enters these variations in the URL, it will redirect to a abc pool. Otherwise, all else goes to xyz pool

 

test.123.com/nice* test.123.com/tree* test.123.com/green* redirect it to abc pool

 

Otherwise, everything else goes into xyz pool

 

     if {[string length [HTTP::host]]}{

       Redirect to the requested host and URI (minus the port if specified)
      if {[HTTP::uri] contains "nice"} {
      pool abc }
      elseif {[HTTP::uri] contains "green"} {
      pool abc }
      elseif {[HTTP::uri] contains "tree"} {
      pool abc }

   } else {

       Redirect to this Pool Member
      pool xyz
   }
}

1 Reply

  • Try this:

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
            "/nice*" -
            "/green*" -
            "/tree*" { pool abc }
            default { pool xyz }
        }
    }