Forum Discussion

Sinistrad_29710's avatar
Sinistrad_29710
Icon for Nimbostratus rankNimbostratus
Jun 22, 2017

Multiple conditions in iRule

Hi,

I'm trying to do multiple conditions in my iRule, however I only have the first condition working, the iRule doesn't go through the second condition:

when HTTP_REQUEST {

if { [HTTP::host] contains "euhreka.apps.com" }{
    HTTP::redirect "https://hr.entreprise.net/tp-hr2/modules/euhreka/euHReka.htm" 
}

if { [HTTP::host] contains "euHReka.hr.com" }{ HTTP::redirect "; } }

Can you please advise what should I change on my iRule to make it works ?

Thank you

1 Reply

  • Is that an exact replication of your iRule? The second 'if' condition includes upper-case characters in the test statement. The HTTP Host header evaluation should be case insensitive. Typically your test string will be all lower-case, and you can take a step further by performing a 'string tolower [HTTP::host]' to ensure the header value is all lowercase, though not necessary in many cases. Change your second test string to "euhreka.hr.com".

     

    (Reference the HTTP::host page on DevCentral)

     

    If the issue was that you could never match to the second 'if' condition, this is likely your issue. There also appears to be a trailing semi-colon after the HTTP::redirect in your second section - was that intentional?