For a company campaign, we want a page to be available only between 2 datess. There a way to allow access to a file only if current date is between 2 dates using .htaccess??

  • mod_rewrite could do that by using a regular expression to match a time and then a RewriteRule with F, I reckon. – 0xC0000022L Jun 6 '12 at 19:45
  • how do i get date & tme in the rewrite rule? – Roy Rico Jun 6 '12 at 19:48
  • Depends on the environment, but environment variables seem like the best take on this. Alternatively use a simple script that does the distinction, gets transparently put in front using a RewriteRule and returns the HTTP status for forbidden when the campaign is over and the contents of some file/folder otherwise. Need to run, this is why I commented and didn't write an answer :) – 0xC0000022L Jun 6 '12 at 19:50
  • ok, you gave me some ideas on where to look. thanks! – Roy Rico Jun 6 '12 at 19:53

mod_rewrite has various TIME variable which you could use in a RewriteCond directive. Based on this post the following works:

RewriteCond %{TIME} <20120607000000
RewriteRule /specialpage - [F]

RewriteCond %{TIME} >20120609000000
RewriteRule /specialpage - [F]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.