Forum Discussion

derek_mccabe_10's avatar
derek_mccabe_10
Icon for Nimbostratus rankNimbostratus
Aug 25, 2006

if - elseif statement not working

Hi All,

 

 

just wondering if you could help a noob out with a simple statement - code is below and i get the following errors:

 

 

line 9: [undefined procedure: elseif] [elseif { [HTTP::host] equals "ghi" } {

 

line 12: [undefined procedure: else] [else {

 

 

when HTTP_REQUEST {

 

 

if { [HTTP::host] equals "www.abc.co.uk" } {

 

use pool abc

 

}

 

elseif { [HTTP::host] equals "www.def.co.uk" } {

 

use pool def

 

}

 

elseif { [HTTP::host] equals "www.ghi.com" } {

 

use pool ghi

 

}

 

else {

 

discard

 

}

 

}
  • please ignore the post guys - didnt realize the positioning of the closing brackets before the elseif was essential - for other noobs that may have similar issues:

     

     

    when HTTP_REQUEST {

     

     

    set host [string tolower [HTTP::host]]

     

     

    if { $host eq "www.abc.co.uk"} {

     

    pool abc

     

    } elseif { $host eq "www.def.co.uk"} {

     

    pool def

     

    } elseif { $host eq "www.ghi-online.com"} {

     

    pool ghi

     

    } else {

     

    discard

     

    }

     

    }
  • I ran into a really dumb way to produce this error....

     

     

    Put two "else" statements against a single "if"..

     

     

    Doh!