Wednesday, May 14, 2014

How To Create A ‘Maintenance’ Holding Page When Upgrading Your WordPress Blog

Before you start to upgrade your existing blog to the latest version of WP, you might want to create a maintenance holding page so that your readers know that your site is temporary down and will resume service in a short time. The last thing that you want to see during upgrading is your site showing a ‘404 error page‘ and all your readers start emailing you to ask what happen.
For basic maintenance/troubleshooting, the Maintenance mode WP plugin works fine to create a Maintenance splash page. But if you are upgrading your WordPress version, the plugin will not work. Here’s a easy way to create a Maintenance holding page that you can use while upgrading to WP2.7.

Creating a Maintenance holding page

Open a text editor. Copy the following code to it and save the file as maintenance.php
<?php
header(“HTTP/1.1 503 Service Temporarily Unavailable”);
header(“Status: 503 Service Temporarily Unavailable”);
header(“Retry-After: 3600″);
?>
<html>
<head>
<title>Site upgrade in progress</title>
<meta name=”robots” content=”none” />
</head>
<body>
<h1>Maintenance Mode</h1>
<p><a title=”Your site” href=”your-site-url”>Your Site name</a> is currently undergoing scheduled maintenance.<br />
Please try back <strong>in 60 minutes</strong>.</p>
<p>Sorry for the inconvenience.</p>
</body>
</html>
If you want to style up your Maintenance page, feel free to do so. The above is only a template that you can use quickly.
Upload it to the parent directory of your site. You’ll need to use a FTP program to upload it. Make sure that the page can be accessed on http://yoursite.com/maintenance.php

Redirecting your readers to the Maintenance page

Next, download your .htaccess file. It is found in the parent directory of your site.
Open it with a text editor. Add the following code to the starting of the page
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.php$
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
RewriteRule $ /maintenance.php [R=302,L]
Go to http://www.whatismyip.com and find out the IP address of your network connection.
Replace the 127\.0\.0\.1 with your IP. This will ensure that you still have access to your site while other people are directed to the Maintenance holding page.
Save the .htaccess file. Upload it to your site.  When it prompts you if you want to overwrite, select Yes.
That’s it. When your readers visit your site, they should see something like
maintenance-mode
Note: When you visit your own site, you won’t be able to see the above maintenance page because you have configured your network to allow your IP address.
You can now perform your WordPress upgrade.

Remove the Maintenance holding page

When you are done upgrading your site, you need to remove the redirect so that your readers can access your blog again.
In the .htaccess file, put a # in front of the code that you inserted just now. It should look like
#Options +FollowSymlinks
#RewriteEngine on
#RewriteCond %{REQUEST_URI} !/maintenance.php$
#RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
#RewriteRule $ /maintenance.php [R=302,L]
Upload it to your site (if prompted whether you want to replace the file, select Yes).
That’s it.
Note:
1) In the future version of WordPress, you may no longer need the Maintenance holding page as there is a feature in WP2.7 that allows you to upgrade your WP right within your dashboard.
2) Although this tutorial is meant for WordPress blog, it will work for any sites and platforms

No comments: