Forum Discussion

Kalpesh_48932's avatar
Kalpesh_48932
Icon for Nimbostratus rankNimbostratus
Oct 05, 2012

irule with Contains operator

Hi All,

 

 

I have created irule, in fact wanted to have similar irule with contains operator.

 

 

when HTTP_REQUEST {

 

if {

 

[HTTP::uri] contains "AMSLang"

 

} then {

 

HTTP::redirect "http://sgsiaxhrmsgr1.saint-gobain.com:8201"}

 

{

 

HTTP::redirect "http://sgsiaxhrmsgr1.saint-gobain.com:8200"}

 

}

 

but it gives error in line 6. can someone please help with this.

 

 

error:

 

01070151:3: Rule [irule_ofx_idispo_ams_1.0] error: line 6: [undefined procedure: HTTP::redirect "http://sgsiaxhrmsgr1.saint-gobain.com:8200"] [{ HTTP::redirect http://sgsiaxhrmsgr1.saint-gobain.com:8200}]

 

Thanks

 

2 Replies

  • No need for the 'then'. Also, you seem to be redirecting twice, should there be another if in there?

    Anyway, this should work for a single redirect;

    
    when HTTP_REQUEST {
    if { [HTTP::uri] contains "AMSLang" } {
    HTTP::redirect "http://sgsiaxhrmsgr1.saint-gobain.com:8201" }
    }
    
  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    Or do you need to redirect all other requests to port 8200?

    when HTTP_REQUEST {
      if {[HTTP::uri] contains "AMSLang"} {
        HTTP::redirect "http://sgsiaxhrmsgr1.saint-gobain.com:8201"
      } else {
        HTTP::redirect "http://sgsiaxhrmsgr1.saint-gobain.com:8200"
     }
    } 

    Hope this helps,

    N