Forum Discussion

cstalker_366429's avatar
cstalker_366429
Icon for Nimbostratus rankNimbostratus
Jul 09, 2018

iRule to break looping

Hi

 

I have dynamic urls and currently my iRule is 'looping' on itself so I need to refine. I have two basic url that need to be handled by one iRule. uri 1: hostname/ uri 2: hostname/webprocess.srv

 

what I am looking for is if I match either of these how do I redirect to uri 3: hostname2/login?

 

I was using contains or equals but getting a loop back on itself and never get to uri 3. any help would be appricated.

 

3 Replies

  • Maybe something like this?

    when HTTP_REQUEST {
        if { ([HTTP::host] equals "hostname" && [HTTP::uri] equals "/") ||
             ([HTTP::host] equals "hostname" && [HTTP::uri] starts_with "/webprocess.srv") } {
             HTTP::redirect "http://hostname2/login"
        }
    } 
    

    Unless hostname2 has some sort of redirect back to hostname, you should not encounter a loop.

  • actually we have tried that, I need to expand on my initial statement, uri 2 includes a query string that is dynamic so it could be uri2: hostname/webprocess.srv?a=1,b=1 or ?a=2,b=2 that was why we were using contains but it loops the first equals on url1 works fine but not the second.

     

  • I amended my answer to change the "equals" on the webprocess.srv check to "starts_with"