Skip to content

Instantly share code, notes, and snippets.

@ar-to
Created January 20, 2017 17:27
Show Gist options
  • Save ar-to/55d4a639dc9ab60b9b5a150515720267 to your computer and use it in GitHub Desktop.
Save ar-to/55d4a639dc9ab60b9b5a150515720267 to your computer and use it in GitHub Desktop.
Maintenance Mode with .htaccess
# serve custom 503 response
ErrorDocument 503 /503.html
# alternate response without custom page
# ErrorDocument 503 "Coming soon!"
#enables mod_rewrite
RewriteEngine On
# If the IP address does not match this one
# Exclude IP
RewriteCond %{REMOTE_ADDR} !^70.180.241.252$
# And they are not accessing a certain subdirectory
RewriteCond %{REQUEST_URI} !^/503 [NC]
#Or
#RewriteCond %{REQUEST_URI} !^/503.html$
#allow other files to pass
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
#Set time in sec to tell search engines to recrawl
# 3600 = 60 minutes
# 86400 = 1 day
# 604800 = 1 week
Header always set Retry-After "3600"
# Or provide a redirect url
RewriteRule .* http://yourdomain.com/503.html [R=503,L]
#server default 503 response
#RewriteRule .* - [R=503]
# alternate response without custom page
# RewriteRule .* - [R=503,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment