Tuncay Sahin

ICT Engineer | Docent ICT & Trainer

This document will show you how to put the site into a maintenance mode, during site updates, without restarting Apache. In this document it’s assumed you already have a custom maintenance page to inform your visitors the site is down for maintenance.

By checking if a maintenance.enable semaphore file exists inside the site’s document root, we can turn the maintenance mode ON and OFF for the website. If the file maintenance.enable is found inside the site’s document root, the maintenance mode is enabled. Otherwise the maintenance mode will be disabled.


Add the following rules to your VirtualHost to redirect your site’s visitors to maintenance page:

RewriteEngine On

# to prevent redirection from listed IP
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4

# Check for the maintenance.enable file
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f

#Don’t apply the rule when serving the maintenance page
RewriteCond %{SCRIPT_FILENAME} !maintenancepage.html

#The 503 redirect to maintenance page itself
RewriteRule ^.*$ /maintenancepage.html [R=503,L]

#Custom 503 Service Unavailable page because it is overloaded or down for maintenance
ErrorDocument 503 /maintenancepage.html

#Avoid caching
Header Set Cache-Control “max-age=0, no-store”

Reload Apache once to apply the new settings:

apachectl graceful

From now you can TURN ON and TURN OFF the maintenance mode, with maintenance.enable file, without restarting Apache.

Meer informatie

Voor meer informatie of voor een persoonlijk adviesgesprek kunt u altijd vrijblijvend contact met mij opnemen.