Created
March 15, 2021 18:29
-
-
Save nilsbosman/32bb043597bda20582c741ae209fa3a1 to your computer and use it in GitHub Desktop.
.htaccess - Maintenance mode with whitelisted IP's
This file contains hidden or 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
# Rewrite url for maintenance mode | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REMOTE_ADDR} !^123\.456\.78\.90 | |
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f | |
RewriteCond %{DOCUMENT_ROOT}/maintenance.true -f | |
RewriteCond %{SCRIPT_FILENAME} !maintenance.html | |
RewriteRule ^.*$ /maintenance.html [R=503,L] | |
ErrorDocument 503 /maintenance.html | |
</IfModule> | |
# Set headers | |
<IfModule mod_headers.c> | |
# 3600 = 60 minutes | |
# 86400 = 1 day | |
Header Set Cache-Control "max-age=0, no-store" | |
Header always set Retry-After "86400" | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the maintenance.true file exists, all traffic will be redirected. I rename the file to maintenance.false for easy switching.