Forum Discussion

Yann_R's avatar
Yann_R
Icon for Nimbostratus rankNimbostratus
Jan 16, 2020

Irule redirect - periodic

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.

 

  • Yann_R's avatar
    Yann_R
    Icon for Nimbostratus rankNimbostratus

    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's avatar
    Yann_R
    Icon for Nimbostratus rankNimbostratus

    Any feedback on this one please ?

    Thanks very much !