Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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??

share|improve this question
    
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
add comment

1 Answer

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

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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