httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From WC -Sx- Jones <>
Subject Re: [users@httpd] Redirect during certain time frame
Date Wed, 28 May 2003 04:47:20 GMT

On Wednesday, May 28, 2003, at 12:40  AM, Denise Mangano wrote:

> Is it possible to redirect all incoming requests to a particular page 
> on my
> server during a specific time frame?


(And yes, these rewrite rules work the same for Apache2.x as well...)

Time-Dependend Rewriting

     When tricks like time-dependend 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?

     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-dependend redirects:

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

     This provides the content of 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...

HTH/Sx =)
  ('>    iudicium ferat
  //\   Have Computer -
  v_/_    Will Hack...

               \|/ ____ \|/
               "@'/ .. \`@"
               /_| \__/ |_\

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message