Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lechup/866425215f360e3d98fb7879e322a292 to your computer and use it in GitHub Desktop.
Save lechup/866425215f360e3d98fb7879e322a292 to your computer and use it in GitHub Desktop.
How to make maintenance mode - Apache

Apache

How to make your website to maintenance mode

  1. Put maintenance.html into your root directory

  2. Open .htaccess file

  3. Insert this block in the first line of the file

     ErrorDocument 503 /maintenance.html
     RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
     RewriteCond %{REQUEST_URI} !(/maintenance.html)
     RewriteRule ^.*$ - [R=503,L]
    
  4. Users except you will be redirected to maintenance.html

  5. To disable maintenance mode just remove maintenance.html

So what does it exactly do?

ErrorDocument 503 /maintenance.html is when user gets error 503, redirect the page to maintenance.html

RewriteRule ^.*$ - [R=503,L] does rewrite any url without replacing the url and access with 503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment