Forum Discussion

Albert_59847's avatar
Albert_59847
Icon for Nimbostratus rankNimbostratus
Mar 10, 2016

Combine redirect iRule doesn't work

Hi All,

 

I have two irules in one of my virtual server and run perfectly. I tried to merge the two irule but no luck, could someone review my merge irule? See below irule.

 

1st irule: when HTTP_REQUEST {

 

if { [HTTP::host] equals "outlook.kw.com.xy"} {

 

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

 

}

 

}

 

2nd iRule: when HTTP_REQUEST {

 

if { [HTTP::host] equals "mail.kw.com.xy"} {

 

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

 

}

 

}

 

Merged iRule (doesn't work): when HTTP_REQUEST {

 

if { [HTTP::host] equals "outlook.kw.com.xy" && [HTTP::host] equals "mail.kw.com.xy"} {

 

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

 

}

 

}

 

Thanks and regards,

 

1 Reply

  • Hi Albert,

    you combined your two if-statements with AND (&&), which will never be true. You need to use or (||). Something like this:

    when HTTP_REQUEST {
        if { ([HTTP::host] equals "outlook.kw.com.xy") or ([HTTP::host] equals "mail.kw.com.xy") } {
            HTTP::redirect "https://[HTTP::host][HTTP::uri]"
        }
    }
    

    Ciao Stefan 🙂