Sometimes when working on a web site you need a quick and dirty “This Site is Down” Maintenance page. WordPress or other similar software may have this feature built-in or through a plugin, but sometimes you may need to put up a page while moving files around using ssh or scp/sftp/ftps.
If you use Apache or an Apache compatible web server that uses .htaccess, the easiest way to generate a maintenance page is to combine the deny/allow directives with a custom 403 page which can be written directly in .htaccess. The directives will allow only your IP address to work on and view the web site while everyone else will see the maintenance page.
This method requires no php or other separate scripts, and no redirects. Enabling the mode is simple – just remove (maintenance mode) or add (go live) the hash comment from two lines ( 21 and 23 in the example below).
Follow these simple steps:
order deny,allow
###################################
# Begin Maintenance Mode Directives
#####################################
# Make sure to put the background image in your document root
<Files background.jpg>
order allow,deny
allow from all
</Files>
# Insert Your workstation ip here. Replace XXX.XXX.X.XXX with your ip address
allow from XXX.XXX.X.XXX
# To enter maintenance mode, uncomment the following 2 lines. The second long "ErrorDocument" line contains a full html page compressed together in one line with no carriage returns (it's just being word-wrapped in the below example).
# deny from all
# ErrorDocument 403 "<html><header><style> body { font: normal normal 24px/60px Georgia, serif; color: white; background-size: 100%; background-repeat: no-repeat; background-image: url('background.jpg'); background-color: black;}</style></header><body><div style= ' box-shadow: 10px 10px #000000; border: 2px solid black; border-radius: 25px; margin: auto; background: #ff5733; padding: 20px; width: 70%;' > <h2 ><center>Joe's Computer Shop</center></h2> <h3><center>Your Local Computer Fix-It Place</center></h3>This Website is Down for Maintenance. Please come back later. We are sorry for any inconvenience.</div> <div style= ' box-shadow: 10px 10px #000000; border: 2px solid black; border-radius: 15px; margin-left: 10px; margin-top: 100px; background: #000000; padding: 20px; width: 14%; font: normal 14px Georgia, serif;' > Joe's Computer Shop <br/>123 Main Street</br> New York, NY 11111<br/> 800-888-8888<br/> </div><a style='background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, "San Francisco", "Helvetica Neue", Helvetica, Ubuntu, Roboto, Noto, "Segoe UI", Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px; margin-top: 20px;' href='https://unsplash.com/@herlifeinpixels?utm_medium=referral&utm_campaign=photographer-credit&utm_content=creditBadge' >Hannah Wei</a></body></html>"
Avoiding Browser Plugins with KeePassXC KeePassXC is a popular free open source password manager. As…
If you've had a Gmail account for years, like I have, at some point you…
Here's a little trick I use to back up my Raspberry Pi without having to…
I try to keep my email inbox fairly clean but I do subscribe to some…
I was recently faced with the dreaded prospect of re-installing Windows 10. While the standard…
Pi-Hole and Upstream DNS Providers Pi-hole is an excellent whole-home, self-hosted ad blocker and DNS…