Forum Discussion

Yozzer's avatar
Yozzer
Icon for Nimbostratus rankNimbostratus
Sep 13, 2012

Parse error: PARSE syntax 372

Hi, I get the following parse error:

 

 

01070151:3: Rule [irule_redirect] error:

 

line 13: [parse error: PARSE syntax 372 {syntax error in expression "

 

return

 

": variable references require preceding $}] [{

 

return

 

}]

 

line 15: [undefined procedure: else] [else]

 

line 15: [deprecated usage, use else or elseif] [ ]

 

 

with this code:

 

when HTTP_REQUEST {

 

 

set name "DC"

 

 

 

if {([string tolower [HTTP::method]] eq "get") && ([string tolower [HTTP::uri]] eq "/") && ([string tolower [HTTP::header "Referer"]] ne "http://cba.com") } {

 

 

 

if {([string tolower [HTTP::cookie value $name]] contains "session=&") } {

 

 

HTTP::redirect "http://www.abc.com"

 

 

} elseif {

 

return

 

} else {

 

HTTP::redirect "http://www.abc.com"

 

}

 

}

 

}

 

 

Any ideas what im doing wrong?

 

 

Thanks

 

2 Replies

  • Hi Yozzer,

    Remove the elseif statement and the return.

    You won't need either. If they qualify the the first event they will be redirected, if not then they will be caught by the else statement and also be redirected (in this case to the same location, but I am assuming that you sanitized the iRule to post it).

    A return statement is only used when there is an event triggered in an iRule and you do something and you do not want any further iRule processing. The return statement will break out and not process any further conditions in the iRule.

    Try this:

    
    when HTTP_REQUEST {
    set name "DC"
    
    if {([string tolower [HTTP::method]] eq "get") && ([string tolower [HTTP::uri]] eq "/") && ([string tolower [HTTP::header "Referer"]] ne "http://cba.com") } {
    if {([string tolower [HTTP::cookie value $name]] contains "session=&") } {
    HTTP::redirect "http://www.abc.com"
    }
    else {
    HTTP::redirect "http://www.abc.com"
    }
    }
    }
    

    Hope this helps.