Forum Discussion

Albert__Tase_70's avatar
Albert__Tase_70
Icon for Nimbostratus rankNimbostratus
Sep 07, 2007

trying to add the below to exsiting irule and keep getting errors please help

} elseif { ($uri starts_with "/dynasearch") || ($uri starts_with "/Dynasearch") || ($uri starts_with "/DynaSearch") } {

 

HTTP::redirect "http://www.palgrave-journals.com/common/access/replaced.vm"

 

} else {

 

pool palgrave-foxtrot

 

} elseif .....

 

 

 

the part i get syntax errors on is adding the else statement above its being added in the middle of the rule show the start of the next elseif statement.

 

 

error message [deprecated usage, use else or elseif] [ ]

 

 

else if (http_uri starts_with "/dynasearch" or http_uri starts_with "/Dynasearch" or http_uri starts_with "/DynaSearch") {

 

redirect to "http://www.palgrave-journals.com/common/access/replaced.vm"

 

}

 

else {

 

use pool palgrave-foxtrot

 

}

 

 

this is in th emiddle of the 4 verserion irule need to get in the 9 version and it just won't let me

 

 

 

 

 

 

atase

 

Posts:40

 

 

09/07/2007 7:50 AM Edit Quote Reply Alert

 

so are yo usaying it can't be converted it would have to go into the end of the rule ? this rule is 91 lines long

 

thanks

 

 

Al

 

 

5 Replies

  • Hi Al,

    The else should be the last clause:

    
    } elseif {
        something
    } elseif {
        something
    } else {
        default action
    }

    Also, you can set the $uri variable to lower case and do just one comparison:

    
    ...
    elseif {[string tolower $uri] starts_with "/Dynasearch"}{
       HTTP::redirect "http://www.palgrave-journals.com/common/access/replaced.vm"
    }
    ...

    Aaron
  • else if (http_uri starts_with "/dynasearch" or http_uri starts_with "/Dynasearch" or http_uri starts_with "/DynaSearch") {

     

    redirect to "http://www.palgrave-journals.com/common/access/replaced.vm"

     

    }

     

    else {

     

    use pool palgrave-foxtrot

     

    }

     

     

    this is in th emiddle of the 4 verserion irule need to get in the 9 version and it just won't let me
  • so are yo usaying it can't be converted it would have to go into the end of the rule ? this rule is 91 lines long

     

    thanks

     

     

    Al
  • The structure for an if statement is normally:

    
    if {some condition}{
        do something
    } elseif {some other condition}{
        do something else
    } elseif {some other condition}{
        do something else
    } else {
        take some default action
    }

    All statements after the first 'if' are optional. Logically, you wouldn't want to put an else anywhere in the middle of the rule, as it would match any case up til then and stop the rule from ever processing any of the subsequent elseif's.

    If you want to perform other tests after the checks you posted, you could change the else to an elseif.

    Also, are you running 9.0.3 or 9.3.0? 9.0.3 is a very old version with a lot of issues. You should consider upgrading to the latest maintenance release in the 9.3.x branch.

    Aaron
  • It is very difficult to try to diagnose problems when you only post a small subset of your iRule (especially when an error is dependent on the other parts of the iRule). If you could post the complete section of your if clause, we might be able to help you better.

     

     

    -Joe