Rule to redirect file based on timestamp?

1.4k Views Asked by At

I need to filter JSON files based on date and time that is present on it's name.

If file name datetime.json is bigger than current time I want to redirect to future.json.

If file name is less than current time, then don't redirect.

For example:

Current date and time is 1377512625. File Name is 1345732202. Current date and time is greater than File Name, then serve 1345732202.json:

http://myserver.com/1345732202.json 

Current date and time is 1377512625. File Name is 1408804202. Current date and time is less than File Name, then serve future.json:

http://myserver.com/1408804202.json

Here is my .htaccess which does not work:

RewriteEngine on
RewriteCond %{TIME} <%{REQUEST_FILENAME} [NC]
RewriteRule ^(.*)\.json$ /future.json [R=307,L]
0

There are 0 best solutions below