Putting WordPress Into Maintenance Mode

Website Under ConstructionWordPress has maintenance mode built into its core that is only accessible during the upgrade function of WordPress but it’s not something that you can just turn on and off.

Here are three ways to put your WordPress CMS into Maintenance Mode, the first 2 methods are manual and the last one is a plugin.

Maintenance Mode with and .htaccess File

Using your .htaccess file is probably the easiest and most effective way to put your WordPress CMS into maintenance mode because it doesn’t rely on the WordPress Core to function. All you have to do is  create an html file, styled however you like with your message to be used as your  maintenance page, upload it to the server. Once the maintenance file is uploaded simply  add the following commands to the .htaccess file, change the url and page parameters and upload.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://www.yourdomain.com/maintenance.html [R=307,L]

To take out of maintenance mode, remove or comment out the commands and re-upload.

Using the .Maintenance File

Built into the WordPress Core is the .maintenance process for putting your WordPress CMS into maintenance mode. This method requires 2 files, maintenance.php and the .maintenance.

Start by creating a file named maintenance.php and save it directly inside the wp-content directory. Design and style this page however you want and add your maintenance or site under construction message. Once you’re done with your design and stuff you need to paste some PHP code into this file. At the very top of this new file you want to paste the following…

$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
$protocol = 'HTTP/1.0';
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );

Then you have to paste the following line of code to the very bottom of the page just outside of the trailing html tag.  <?php die(); ?>

Next we need create the .maintenance file and save it to the root directory of the website, which is the same directory that your wp-config.php file lives in. Once you have created the file copy and paste the following code into the .maintenance file. This should be the only code on the page.
<?php $upgrading = time(); ?>

Upload maintenance.php to your wp-content directory. To initiate maintenance mode with this method all you need to do is upload .maintenance to the root directory. Once you are done with maintenance simply delete .maintenance and everything should be ready to go.

Maintenance Mode Plugin

Probably by far the easiest way to put WordPress into Maintenance Mode is to use the WordPress Maintenance Mode Plugin.

With the WordPress Maintenance Mode Plugin all you have to do is upload the uncompressed zip into the wp-content/plugins/ directory, activate it via the plugins panel, customize your maintenance settings and enable at will. Visit the WordPress Plugin Repository to download WordPress Maintenance Mode.

2 Responses to “Putting WordPress Into Maintenance Mode”

  1. seth says:

    can this be worked with wordpress .com or .org?

  2. Sammy Russo says:

    The first two will only work with .org… the self installed version of WordPress. I don’t work with WordPress DOT com at all so I’m really not sure if the maintenance mode plugin works there or not. I imagine it would.


Post Comments, Questions and Feedback