Static maintenance page to replace Drupal's default 'maintenance mode' page

When updating or doing maintenance on a Drupal site you can switch it into the default 'Maintenance mode' via the site UI (/admin/config/development/maintenance).

There are a couple of problems with this maintenance page though:

  1. it defaults to your admin theme, which is often different to the front-end theme
  2. if you are making DB updates you will get a broken page rather than the maintenance message

A good way to do this is to create a static html page which you can bring up when required. The below solution uses settings in your root .htaccess file, and lets you replace your site with to a static html page just by renaming a file.

Step 1: Add code snippet to .htaccess

The below code should be added to your sites root .htaccess file within the mod_rewrite section. Look for <IfModule mod_rewrite.c> and place it after the RewriteEngine On tag .

#add maintenance page
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
#end of adding maintenance page

Step 2: Create the static html maintenance page

Create a page in your site root called maintenance.html. This is the page that will contain your maintenance message, and since it's just a regular html file to you can style it as you like.

Step 3: Create file to trigger switch to custom maintenance page

In order to bring up the static maintenace page you will need a file in your site root called maintenance.enable. As it's the name that's important this can just be an empty .txt file which has been renamed. . Basically the code that was added to the .htaccess file will pick up when a file of this name exists and cause the switch.

So once you have added a file with this name your site should be replaced with the static maintenance page. When you want to bring your site back up just rename this file to something like maintenance.enableOFF or maintenance.disable.

BTW. it can take a little while for the file to be detected and for the switch to happen, but in my experience this is under 10 seconds.

Justin Chevallier

Justin Chevallier

Avid Drupal site builder & user for +10 years.


Submitted by Robby Douglas on

I've been Googling for what seems half my life trying to find a simple way to make a static html page when in maintenance without fighting with Drupal. Thanks very much.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.