Skip to content

Instantly share code, notes, and snippets.

@earth3300
Last active August 29, 2018 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save earth3300/929ff840224a618c1387bbeac02dd664 to your computer and use it in GitHub Desktop.
Save earth3300/929ff840224a618c1387bbeac02dd664 to your computer and use it in GitHub Desktop.
Time of day based page dispaly.
# Time of day based page display.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# 5am > < 8am
RewriteCond %{TIME_HOUR} >02
RewriteCond %{TIME_HOUR} <05
RewriteRule ^index\.html$ /page/time-of-day/morning.html
# 8am > < 4pm
RewriteCond %{TIME_HOUR} >05
RewriteCond %{TIME_HOUR} <13
RewriteRule ^index\.html$ /page/time-of-day/midday.html
# 4pm > < 10pm
RewriteCond %{TIME_HOUR} >13
RewriteCond %{TIME_HOUR} <19
RewriteRule ^index\.html$ /page/time-of-day/afternoon.html
# 10pm > < 5am
RewriteCond %{TIME_HOUR} >19
RewriteCond %{TIME_HOUR} <02
RewriteRule ^index\.html$ /page/time-of-day/night.html
</IfModule>
# Displays a different page, depending on the time of day.
# @link https://www.askapache.com/htaccess/time_hour-rewritecond-time/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment