When you update your WordPress blog platform, or when you fix bugs on your WordPress theme , your blog becomes, or shall be inaccessible for some time. You obviously noted that WordPress shows “maintenance mode activated” in the panel.
Worse if you perform a cleanup, it will take an hour or more.
Instead of losing visitors from search engine during this few seconds to minutes, you might want to redirect visitors to a page explaining that the blog website is undergoing maintenance and that would be accessible again soon.
---
It is true that there are Maintenance Mode plugin for WordPress that allows you to easily create a page where maintenance will be automatically directed to readers. This plugin works great, you can customize the maintenance message, announcing the return of the blog in X minutes, etc. except for major upgrade of WordPress when you have to disable all plugins to avoid major problems. We had to find another way to implement this maintenance page. After some research and unsuccessful attempts, we finally found a solution that works very well based on .htaccess with special maintenance page and a news page that announces maintenance.
The maintenance page
This page will be displayed on the browser that the visitor arriving at your blog for maintenance:
<?phpob_start();header('HTTP/1.1 503 Service Temporarily Unavailable');header('Status: 503 Service Temporarily Unavailable');header('Retry-After: 3600');header('X-Powered-By:');?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Blog is under maintenance</title><meta name="robots" content="none" /></head><body><!-- Your custom message --></body></html>
It uses the HTTP code 503 which means that the server is currently unavailable due to overloading or maintenance. Moreover, the code 503 is accompanied by another message indicating the robots not to index this page (content = “none”).
Just drop this file now “503.php” in the root of your web server.
.Htaccess special maintenance
This file is not to replace your present .htaccess, this is for special maintenance that will be activated at the time of maintenance. Name this file as 503.htaccess, when you want to activate your maintenance, simply rename the existing .Htaccess to temporay.htaccess and 503.htaccess to .htaccess. More clearly: it activates one or the other of two files by renaming them.
Options +FollowSymLinksRewriteEngine OnRewriteBase /RewriteCond %{REMOTE_ADDR} !^ 123 \. 123 \. 123 \. 123RewriteCond %{REQUEST_URI} !^/503.php [NC]RewriteRule .* /503.php [L]
The 4th line should be modified according to your IP address for your blog is still accessible to you and only during maintenance.
And now, with these two small files you can update your blog quietly while preventing your readers that your blog will be back online after maintenance. This way you will avoid to submit a blog all broken and not working during this time.
Good idea. In this case, we simply took the site down for a few hours so a 503 probably wasn?t necessary. Great suggestion for longer cases though.