Mod rewrite Code Library

Code Library - Date or Time Based page delivery

Content Delivery
Date or Time based Delivery of content

By Year

htaccess code
RewriteEngine on
#Hour and Minute
#Shows up only in year 2006
RewriteCond %{TIME_YEAR} ^2006 [OR]

RewriteRule ^index.htm$ /index.html[L]

By Month

htaccess code
RewriteEngine on
#Hour and Minute
#Shows up only in March and April
RewriteCond %{TIME_MON} >02 [OR]
RewriteCond %{TIME_MON} >05

RewriteRule ^index.htm$ /index.html[L]

By Day

htaccess code
RewriteEngine on
#Hour and Minute
#Shows up only on a day that ends in 9
RewriteCond %{TIME_DAY} ^.?9

RewriteRule ^index.htm$ /index.html[L]

Hour

htaccess code
RewriteEngine on
# Hour only Rewrite
#Shows up only at 11:00 - 11:59 am
RewriteCond %{TIME_HOUR} >10 [OR]
RewriteCond %{TIME_HOUR} <12 [OR]

RewriteRule ^index.htm$ /index.html[L]

By Minute

htaccess code
RewriteEngine on
#Hour and Minute
#Shows up only between 11:01:01 - 11:01:59am
RewriteCond %{TIME_HOUR}%{TIME_MIN} >1101 [OR]
RewriteCond %{TIME_HOUR}%{TIME_MIN} <1102 [OR]

These are great for Holiday, Special Event pages. You can build the page and set the code up in the .htaccass file and it will automatically switch on and off as the year/month/day/hour/min/sec permit.

home | blog | tutorials | code library

 

Mod Rewrite (Home) | Mod Rewrite Tutorials | Directory | Code Library | Blog | Milking Asteroids