Forum Discussion

Ganesh_124122's avatar
Ganesh_124122
Icon for Nimbostratus rankNimbostratus
Feb 19, 2013

[http::host] inside "when rule_init"

Hi,

 

I am very new to this irule scripting, frankly saying first time i am using. I am planning to use the below code snippet for redirecting urls

 

 

when RULE_INIT

 

{

 

switch -glob [string tolower [HTTP::host]]

 

{

 

"*xxx*"

 

{

 

set static::external "xxx.abc.com"

 

set static::internal "xxx.internet.abc.com"

 

}

 

"*yyy*"

 

{

 

set static::external "yyy.abc.com"

 

set static::internal "yyy.internet.abc.com"

 

}

 

"*zzz*"

 

{

 

set static::external "zzz.abc.com"

 

set static::internal "zzz.internet.abc.com"

 

}

 

 

}

 

}

 

 

based on the external and internal value there is some other logic involved in "when HTTP_REQUEST" and "when HTTP_RESPONSE", my doubt is will [HTTP::host] get the value inside "when RULE_INIT". will the above snippet works? if not what is the solution for that?

 

 

Thanks in advance

 

Ganesh.

 

1 Reply

  • You are correct, the HTTP::host command is not available in the RULE_INIT event. You could set all those variables in a number of ways in different events but perhaps you can explain what they are used for first so we can recommend the most suitable.