Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
.htacess/httpd.conf maintenance mode changes
RewriteEngine On
# If this file (toggle file) exsists then put the site into maintenance mode
RewriteCond /path/to/where/your/toggle/file/is/located/on/the/server -f
# If coming from approved ip address, then don't put it into maintenance mode,
# here I'm using HTTP:x-forwarded-for in place of REMOTE_ADDR this is because some users (or your yourself) might
# arrive to the site via a proxy server, so it's more accurate to use HTTP:x-forwarded-for to get the real ip address,
# Also please note that the ip address below has '\' in them because HTTP:x-forwarded-for returns or stores the ip address as a comma delimited list
RewriteCond %{HTTP:x-forwarded-for} !^127\.127\.127\.127$
# redirect to the maintenance mode page
RewriteRule ^(.+) /path/to/the/maintenance/mode/directory/or/index.html/$1 [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.