Dead Simple PHP Maintenance Lock Out

Here’s a quick and dirty way to lock people out of viewing your PHP site while you’re working on it. Put this in a base file or at the top of any page that you don’t want rendered.

<?php if (!isset($_GET["maint"])) { exit("Working... come back later!"); } ?>

You can view it by appending ?maint to all the URLs, which normal visitors won’t know. Of course, you can use other attribute names or text.

Is this the most secure way to do it? Definitely not. But for most purposes, it’s totally fine.