Search code examples
iismod-rewriteurl-rewritingisapi

Time-Dependent Rewriting and single digit TIME_MON/TIME_DAY variables


I am trying to redirect access to one part of my site before a certain date. I am using ISAPI_Rewrite 3 on IIS 6 but I believe ISAPI_Rewrite is compatible with mod_rewrite syntax. Imagine I wanted to redirect pages to a certain address before the 1st April 2012. I have found examples where people use something like this:

RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} <20120401

The problem I have is that the server variables for TIME_MON and TIME_DAY appear to be returning single digits (e.g. 1 rather than 01).

So for the 1st May %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} returns 201251 rather than 20120501.

201251 is less than 20120401 BUT the first of May is AFTER the first of April.

How do I get around this problem?


Solution

  • Looking at Time based rewrites - how to handle two seperate years? I have realised that I may be coming at this from the wrong direction.

    I think something like the following could work for me:

    RewriteCond %{REQUEST_URI} ^/Someplace/(.*)\.aspx$
    RewriteCond %{TIME_YEAR} ^2012
    RewriteCond %{TIME_MON}  <4
    RewriteRule ^(.*)$ /Someplace/systemdown.html [R=301,L]