Forum Discussion

kpdillon_107210's avatar
kpdillon_107210
Icon for Nimbostratus rankNimbostratus
Jun 13, 2008

irule with date check possible?

Hi, just started using some basic irules. I was wondering if it's possible to write an irule that says perform a redirect if date is < than say 7/4/2008... Anything like that possible?

1 Reply

  • Sure it's possible. By using the TCL clock command it's rather simple:

     

     

    Something like this should do the trick:

     

     

    when HTTP_REQUEST { 
       if { [clock seconds] < [clock scan {2008-07-04}] } { 
         HTTP::redirect "http://someothersite" 
       } 
     }

     

     

     

     

     

    The clock command uses the number of seconds since the epoch (1970/01/01-00:00:00) if you were interested.

     

     

    *warning, this hasn't been tested so give it a little bit of testing first.

     

     

    Oh, and if you want to optimize the iRule a bit, log out what the value is from the "clock scan" command and hard code that in. That way you won't need to parse the date each time a request comes in.

     

     

    One more thing... The tech tip I wrote on iRule Maintenance Windows might be of some interest to you as well:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=70

     

    Click here

     

     

     

    Hope this helps...

     

     

    -Joe