If my site crashes, or I have to take it offline for maintenance, I want to redirect all traffic to a temporary ‘Down for Maintenance’ page. And I want to get the page up quickly, so my visitors are greeted by a relatively friendly page, not just an error. It seems a good practice to be proactive and create a simple ‘Down for Maintenance’ html page and htaccess file to redirect traffic, so that both are ready to deploy in a jiffy when needed.
There are various ways to achieve a ‘Down for Maintenance’ page. Perishable Press offers good advice on one approach. Another approach – one that I prefer – is to create a custom 403 error page. All visitors that are denied access to the site will be redirected to the 403 page. I can deny access to all IPs except my current IP, so that I can work on the site to fix it. Fortunately I can easily find my current IP address just by asking Google.
When I need to take my site down for maintenance, I place the following code in my site’s root htaccess file:
# wppov.com htaccess for Maintenance Mode
# BEGIN Maintenance Mode
# *** Remember to: Pause CloudFlare; Enter allowed IP address(es) ***
# Point 403 errors to Maintenance page
ErrorDocument 403 /maintenance.html
# Block all IPs except for me
Deny from all
Allow from 184.108.40.206
# END Maintenance Mode
I need to remember to take this code back out of htaccess when my site is ready for visitors again.
My maintenance page is …
<title>Maintenance Mode | a WP Point of View</title>
<p style="text-align: center; font-size: 2em; font-family: Verdana, Arial, Helvetica, sans-serif;">a WordPress Point of View </p>
<p style="text-align: center; color: #000080; font-size: 1.5em; font-family: Verdana, Arial, Helvetica, sans-serif;">wppov.com has been temporarily taken offline for maintenance</p>
<p style="text-align: center; font-size: 1.2em; font-family: Verdana, Arial, Helvetica, sans-serif;">Something broke. I am working to fix it.</p>
<p style="text-align: center; font-size: 1.2em; font-family: Verdana, Arial, Helvetica, sans-serif;">Sorry for the inconvenience. Please try again later.</p>
<p style="text-align: center;"><img src="wppov-logo.png"></p>
WPPOV supports freedom from Net Neutrality and the GDPR. The Internet of the people, by the people, for the people, shall not perish from the Earth.