Create a Maintenance Page in WordPress

Sometimes when you are doing updates or scheduled maintenance for your WordPress blog, I suggest making the site temporarily down while you are working. A short temporary outage won’t cause any harm to your website — your visitors will understand and can come back later. As for crawl bots from search engines, when they see HTTP Error 503 (Service Unavailable), they will come back again to index your website.

How to create a maintenance page:

1. Make a design for your maintenance page. Smashing Magazine compiled some good and inspirational maintenance pages. Or see mine here.

2. Create a maintenance.php page and put this code in the header or at the top of the script:

ob_start();
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
header('X-Powered-By:');
//Put your design in HTML to the rest

3. Add this to your .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^125.162.xx.xx #Don't block your own ip
RewriteCond %{REQUEST_URI} !^/maintenance.php$ [NC] #Prevent forever loop
RewriteCond %{REQUEST_URI} !.(jpe?g?|png|gif) [NC] #Give access to image
RewriteRule ^(.*)$ http://www.ivankristianto.com/maintenance.php [R=302,L] #temporary redirect

4. Upload everything and you are done.

5. If you want to disable it, comment it out in .htaccess:

RewriteEngine On
RewriteBase /
#RewriteCond %{REMOTE_ADDR} !^125.162.xx.xx #Don't block your own ip
#RewriteCond %{REQUEST_URI} !^/maintenance.php$ [NC] #Prevent forever loop
#RewriteCond %{REQUEST_URI} !.(jpe?g?|png|gif) [NC] #Give access to image
#RewriteRule ^(.*)$ http://www.ivankristianto.com/maintenance.php [R=302,L] #temporary redirect

The above method manually creates the maintenance page and uses .htaccess to redirect. That method applies to any website, not just WordPress. For WordPress specifically you can do it in 2 ways:

1. Use the .maintenance and maintenance.php files

Create a maintenance.php (see the instructions above) and put it under the wp-content/ folder.

Create a .maintenance file with this content:

<?php $upgrading = ' . time() + (60 * 60) . '; ?>

Note: that script always adds 1 hour, so it will be endless. When you finish updating or doing maintenance, just delete or rename the .maintenance file so the site returns to normal.

2. WP Maintenance Mode Plugin
The first 2 methods require a little programming skill. If you don’t have that, you can use the WP Maintenance Mode plugin, available free in the WordPress plugins repository. WP Maintenance Mode adds a maintenance page to your blog that lets visitors know your blog is down for maintenance. Visit the plugin page for more details and the download link: WP Maintenance Mode.

Of all the methods I like the manual .htaccess method best, because it is more general and I can use it with different CMS systems, not just WordPress. And it gives me more power to customize. But you may have a different opinion — feel free to share your thoughts in the comment box below. Thanks and have a nice day.