Apache:Bloqueando o acesso a um site pelo Horario

From Wiki
Revision as of 21:10, 10 March 2010 by Ebasso (talk | contribs) (New page: Já enfrentei situações onde o cliente queria limitar o acesso ao correio somente no horário de trabalho. Com o item abaixo conseguimos fazer isso '''Time-Dependent Rewriting''' ''...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Já enfrentei situações onde o cliente queria limitar o acesso ao correio somente no horário de trabalho. Com o item abaixo conseguimos fazer isso



Time-Dependent Rewriting

Description:

When tricks like time-dependent content should happen a lot of webmasters still use CGI scripts which do for instance redirects to specialized pages. How can it be done via mod_rewrite?

Solution:

There are a lot of variables named TIME_xxx for rewrite conditions. In conjunction with the special lexicographic comparison patterns <STRING, >STRING and =STRING we can do time-dependent redirects:

RewriteEngine on
RewriteCond   %{TIME_HOUR}%{TIME_MIN} >0700
RewriteCond   %{TIME_HOUR}%{TIME_MIN} <1900
RewriteRule   ^foo\.html$             foo.day.html
RewriteRule   ^foo\.html$             foo.night.html

This provides the content of foo.day.html under the URL foo.html from 07:00-19:00 and at the remaining time the contents of foo.night.html. Just a nice feature for a homepage...