Using .htaccess with Apache rewriting rules

At the top of an .htaccess file in the root of the document root, add the following stanza, inserting the site’s own URL, which can be commented in our out as required:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance.html$
RewriteRule ^(.*)$ https://SITE_URL/maintenance.html [R=307,L]
</IfModule>

Then create a maintenance.html HTML file:

<!DOCTYPE html>
<html>
<head>
<title>Maintenance / Deactivation</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
    text-align: center;
    padding: 10%;
    font: 22px Helvetica, sans-serif;
    color: #333;
}
h1 {
    font-size: 50px;
    margin: 0;
}
article {
    display: block;
    text-align: left;
    max-width: 650px;
    margin: 0 auto;
}
a {
    color: #dc8800;
    text-decoration: none;
}
a:hover {
    color: #333;
    text-decoration: none;
}
@media only screen and (max-width : 480px) {
	h1 {
		font-size: 36px;
	}
}
</style>
</head>
<body>

<article>
	<h1>This site is currently undergoing maintenance.</h1>
</article>

</body>
</html>