How to quickly put your website to maintenance mode

Under construction
Rate this post

Sometime we need to put off a website for security reasons. For example when a customer get a malware or the site is hacked and we must organize well to cover all the points that are needed:

  • Clients must reach the website with maintenance page, put there all usefull information.
  • SEO problem: the pages must not have a redirect 301 or 302!! error 503 is a better solution.
  • You need to exclude yourself for diagnostic purpose.

Time Needed : 0 days 0 hours 3 minutes

These steps work with Apache:

  1. Create an HTML page like that maintenance.html on you root's site.

    <h1>This site is temporarily under maintenance.</h1>
    <h2>Will be back soon, please come back later.</h2>

  2. Enter this text on top of your .htaccess .

    ErrorDocument 503 /maintenance.html
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
    RewriteRule ^.*$ - [R=503,L]

  3. Happy hunting!

    Now you can find and fix the problem!
    When you finished remove all lines you put on your .htaccess file

ErrorDocument 503 /maintenance.html means that if client get a 503 error will be redirect to maintenance page

RewriteCond %{REMOTE_ADDR} !=<YOURIPADDRESS> helps you to reach your site!

RewriteRule ^.*$ - [R=503,L] put a 503 error without change the URL.

You may also like...