Switch WordPress into Maintenance Mode without a Plugin

This morning I was looking for a quick and dirty way to turn maintenance mode on in WordPress. I normally do this using a .htaccess file but but that required more time then I had. I found a quicker way to do it...

Create a file called .maintenance and copy the line below into it and ftp upload to your wordpress root folder:
<?php $upgrading = time(); ?>

That will tell WordPress to display a maintenance page as long as the file exists in the root directory.

You can also specify how long the site will be offline using something like:
<?php $upgrading = 1344567890; ?>

The number above is a unix timestamp, try the link below to create your own.
http://www.onlineconversion.com/unix_time.htm

One negative is that everyone, including the admin is locked out until you remove the .maintenance file. That's why I normally use an .htaccess file and allow access by IP.

Here a quick paste on how to do that. Paste the following in your .htaccess file and upload to the WordPress root folder. Works with Debian / Apache.

Options -MultiViews +FollowSymLinks
RewriteEngine On

#TEMP MAINT PAGE
RewriteCond %{REMOTE_ADDR} !^123\.45\.6\.111$
RewriteRule !under-development-explain.html$ /under-development-explain.html [R=302,L]

Reference for .maintenance trick:
http://sivel.net/2009/06/wordpress-maintenance-mode-without-a-plugin/