Forum Discussion

mike_gatti_6169's avatar
mike_gatti_6169
Icon for Nimbostratus rankNimbostratus
May 17, 2007

Using array/class to define veriable and use for redirect

I have been trying to use an array or class to define a variable that will be used for a redirect. The iRule that I have created (and not working) is:

 

 

when RULE_INIT {

 

array set sites {

 

/site1

 

/site2

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::uri] starts_with $::sites] } {

 

HTTP::redirect "http://www.domain.com/global/[string range [HTTP::uri] 1 end]"

 

}

 

elseif { [HTTP::uri] starts_with "/global" } {

 

use pool site_pool

 

}

 

}

 

 

I am new to TCL and not sure if this is correct.

 

----------------------------------------------------

 

I also tried to use class and got a syntax error.

 

 

when RULE_INIT {

 

class sites {

 

“/site1”

 

“/site2”

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::uri] starts_with $::sites] } {

 

HTTP::redirect "http://www.domain.com/global/[string range [HTTP::uri] 1 end]"

 

}

 

elseif { [HTTP::uri] starts_with "/global" } {

 

use pool site_pool

 

}

 

}

 

 

Trying this I received a syntax error:

 

 

[undefined procedure: class] [class sites {

 

“/site1”

 

“/site2”

 

}

 

 

 

Any help is very welcome.

 

 

Thanks

 

Mike