Skip to content

Instantly share code, notes, and snippets.

@u01jmg3
Last active March 30, 2023 13:28
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 u01jmg3/3f2322ba6854c79fb43075e56de285a7 to your computer and use it in GitHub Desktop.
Save u01jmg3/3f2322ba6854c79fb43075e56de285a7 to your computer and use it in GitHub Desktop.
Maintenance Mode
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_env.c>
# Scheduled Maintenance
RewriteRule ^ - [E=MAINTENANCE_DATE:False]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230509 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230523 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230613 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230627 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230711 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230725 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230808 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230822 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230912 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20230926 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20231010 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20231024 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20231114 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20231128 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20231212 [OR]
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} 20231226
RewriteRule ^ - [E=MAINTENANCE_DATE:True]
# Every 2nd/4th Wednesday, 6-8am
RewriteCond %{REMOTE_ADDR} !^99\.99\.99\.99$
RewriteCond %{ENV:MAINTENANCE_DATE} =True
RewriteCond %{TIME_WDAY} =3
RewriteCond %{TIME_HOUR}%{TIME_MIN} >0559
RewriteCond %{TIME_HOUR}%{TIME_MIN} <0800
RewriteRule .*$ https://www.mysite.com/maintenance/?url=%{REQUEST_URI} [L]
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment