Last active
August 29, 2018 14:35
-
-
Save earth3300/ecbd12faf9f83d895e2f7e3a1303e9ca to your computer and use it in GitHub Desktop.
Time based routing (.htaccess)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Logic based routing. | |
# STEP 1. BASED ON TIME. | |
# A. If the time is between 9 AM and 5 PM (local), we are open. | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{TIME_HOUR} <18 | |
RewriteCond %{TIME_HOUR} >08 | |
RewriteRule ^s/(.*) /s/open/$1 [L] | |
</IfModule> | |
# B. If the time is between 5 PM and 9 AM (local), we are closed. | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{TIME_HOUR} >17 | |
RewriteCond %{TIME_HOUR} <09 | |
RewriteRule ^s/(.*) /s/closed/$1 [L] | |
</IfModule> | |
# STEP 2. BASED ON DEVICE. | |
# A. If the device is a smartphone, deliver less content | |
# B. If the device is a desktop, deliver more content | |
# C. If the device is a tablet, deliver more or less content based on time. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment