Forum Discussion

Gill_32697's avatar
Gill_32697
Icon for Nimbostratus rankNimbostratus
Jan 31, 2017

Add elseif is to iRule syntax errors

This iRule was working originally but now I need to add a If in the beginning and move /mrgram to an esleif...I cant get the syntax working, I could use some help.. Logic is... 1. If uri starts with /WebTrans/webs.aspx > redirect to othersite 2. Elseif uri starts with mgram/mgram & not one of valid IPs send redirect back as host. 3. othewise continue normal. ! when HTTP_REQUEST { if { ( [string tolower [HTTP::uri]] starts_with "/WebTrans/webs.aspx*" ) } { HTTP::redirect "; elseif { ( [string tolower [HTTP::uri]] starts_with "/mgram/mgram.asmx" ) } { if { not ( [IP::addr [IP::client_addr] equals "10.10.10.10"] or [IP::addr [IP::client_addr] equals

 

"20.20.20.20"] or [IP::addr [IP::client_addr] equals "30.30.30.30"] ) } { HTTP::redirect "https://[HTTP::host]/" } } }

 

1 Reply

  • Try this notation:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/WebTrans/webs.aspx*" } {
            HTTP::redirect "https://othersite.bigfcu.org/"
        } elseif { [string tolower [HTTP::uri]] starts_with "/mgram/mgram.asmx" } {
            if { not ( [IP::addr [IP::client_addr] equals "10.10.10.10"] or [IP::addr [IP::client_addr] equals "20.20.20.20"] or [IP::addr [IP::client_addr] equals "30.30.30.30"] ) } {
                HTTP::redirect "https://[HTTP::host]/"
            }
        }
    }