Forum Discussion

jaddie_85451's avatar
jaddie_85451
Icon for Nimbostratus rankNimbostratus
Feb 15, 2017

iRule syntax

Good morning

I am a novice at iRules and am having some issues with syntax of this iRule, this is the error I am getting in the iRules editior, any suggestions or help would be appreciated.

    when HTTP_REQUEST {
if { ( [class match [string tolower [HTTP::header User-Agent]] contains useragentstoredirect]) }{ 
         HTTP::redirect "https://xyz.sharepoint.com/Help/Pages/Supported-Browsers.aspx" 
    } else {
        set redirect_path [URI::encode(“https://xyz.sharepoint.com[HTTP::uri]”)]
        HTTP::respond 302 Location “https://login.microsoftonline.com/login.srf?wa=wsignin1.0&whr=xyz.com&wreply=$redirect_path“
}
}




Exception: Common::OperationFailed
    primary_error_code   : 17236305 (0x01070151)
    secondary_error_code : 0
    error_string         : 01070151:3: Rule [/Common/iRuler_Parse_Test_Rule] error: /Common/iRuler_Parse_Test_Rule:1: error: [braces are required around the expression][when HTTP_REQUEST {
if { ( [class match [string tolower [HTTP::header User-Agent]] contains useragentstoredirect]) }{ 
         HTTP::redirect "https://xyz.sharepoint.com/Help/Pages/Supported-Browsers.aspx" 
    } else {
        set redirect_path [URI::encode(“https://wegmans.sharepoint.com[HTTP::uri]�)]
        HTTP::respond 302 Location “https://login.microsoftonline.com/login.srf?wa=wsignin1.0&whr=xyz.com&wreply=$redirect_path“
}

1 Reply

  • I am not near my F5 to test it but I would recommend the following:

     

    1. Remove the () brackets from the if-statement.

       

    2. Add a blank space between }{ at the end of the if-statement.

       

    3. Check URI encode syntax.