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

Misty_Spillers_'s avatar
Misty_Spillers_
Icon for Nimbostratus rankNimbostratus
May 19, 2014

Can I have a iRule do 2 actions when it matches a uri?

Can I have a iRule do 2 actions when it matches a uri? Everything I try seems to end up in a loop.

 

This is the logic I was looking for:

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] starts_with "/app1" } {

 

HTTP::redirect "http://www.company.com/app1/app/login.aspx") and (pool app1) really all I want to add on is /app/login.aspx

 

} else {

 

pool everythingelse

 

}}

 

Thanks in advance!

 

2 Replies

  • Well, there's two things going on here.

    1. First, you cannot send to a pool and redirect at the same time. It's conflicting logic.

    2. You're causing a loop because your redirect always matches the first condition. If URI starts with /app1, redirect to /app1/app/login.aspx...and repeat indefinitely. Your best bet may be to be more specific with your condition. Something like this:

      when HTTP_REQUEST {
          if { [string tolower [HTTP::uri]] equals "/app1" } {
              HTTP::redirect "http://[HTTP::host]/app1/app/login.aspx"
          } elseif { [HTTP::uri] equals "/app1/app/login.aspx" } {
              pool app1
          } else {
              pool everythingelse
          }
      }
      
  • Or perhaps this:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] equals "/app1" } {
            HTTP::redirect "http://[HTTP::host]/app1/app/login.aspx"
        } elseif { [HTTP::uri] starts_with "/app1/" } {
            pool app1
        } else {
            pool everythingelse
        }
    }