Skip to content

Instantly share code, notes, and snippets.

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 garthhumphreys/8fe0308ed12cca1816a4ba3fb88da255 to your computer and use it in GitHub Desktop.
Save garthhumphreys/8fe0308ed12cca1816a4ba3fb88da255 to your computer and use it in GitHub Desktop.
.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