cancel
Showing results for 
Search instead for 
Did you mean: 

Irule redirect - periodic

Yann_R
Nimbostratus
Nimbostratus

Hello all,

I'm looking for a way to create an Irule redirecting to 2 different uri depending of the period of the year.

Example : I want this url https://blabla from 2020/02/20 to 2020/08/20 and this url https://blablabla from 2020/08/21 to 2020/02/19.

I hope my question is clear enough.

I couldn't find anything about date and time in irules on dev/central.

Thanks for your help.

 

3 REPLIES 3

Lidev
MVP
MVP

Hello Yann ,

 

You need to use START_OFF_TIME and END_OFF_TIME commands on your iRule.

https://devcentral.f5.com/s/question/0D51T00006j3fU3/irule-to-block-access-of-vs-on-specific-days

 

Yann_R
Nimbostratus
Nimbostratus

Dear Lidev,

 

Thanks for your quick answer.

I'm not sure at all about my code, can you please review it and let me know your thought ?

 

when RULE_INIT {

set static::START_DATE "2020-02-21 00:00"

set static::END_DATE "2020-08-14 00:00"

}

when HTTP_REQUEST {

if { ( [clock seconds] < $static::START_DATE) || ( [clock seconds] > $static::END_DATE) } {

switch -exact [HTTP::uri] {

 

"/uriname" {HTTP::redirect "https://www.blabla.html"}

 

else

switch -exact [HTTP::uri] {

 

"/uriname" {HTTP::redirect "https://www.blablabla.html"}

}

}

 

Thanks,

 

 

Yann_R
Nimbostratus
Nimbostratus

Any feedback on this one please ?

Thanks very much !