General Apache related solution. It is work on any website not only Magento based.
- Create maintenance.html with any text you want. You just may place even your logo here
- Edit .htaccess file and add the following code:
RewriteEngine on
# Point your IP here
RewriteCond %{REMOTE_ADDR} !^11\.11\.11\.11
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
# If you use logo in your maintenance.html
RewriteCond %{REQUEST_URI} !^/path/to/logo\.gif$
RewriteRule ^(.*)$ http://www.domain.com/maintenance.html [R=307,L]
Any web server solution (if you have nginx webserver without an ability to edit nginx.conf, etc)
- Create maintenance.php
<?php
define("SITE_NAME","Enter Site Name");
define("SITE_TITLE", "Site is down for maintenence - %s");
// MAINTENANCE
$conditions = array(
array("REMOTE_ADDR" => "!^(11\.11\.11\.11)"), //your IP here
);
$rules = array(
"^(.*)$"
);
$result = true;
foreach ($conditions as $cond) {
$serverVar= key($cond);
$regexp = current($cond);
$negate = false;
if (substr($regexp, 0, 1) == "!") {
$negate = true;
$regexp = substr($regexp, 1);
}
if (!empty($_SERVER[$serverVar])) {
$condResult = preg_match( '~'.$regexp.'~i', $_SERVER[$serverVar], $params );
if ($negate) {
$condResult = !$condResult;
}
$result &= $condResult;
}
}
if ($result) {
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo printf(SITE_TITLE, SITE_NAME);?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body { text-align: center; padding: 150px; }
h2 { font-size: 30px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
.blog {display: block; margin: 30px auto 0px auto; font-size: 30px; font-weight: bold; color: #f26c4f;}
</style>
</head>
<body>
<article>
<h1 class="blog"><?php echo SITE_NAME;?></h1>
<h2>Site is temporary unavailable.</h2>
<p>We are currently performing scheduled maintenance. Site will back soon.</p>
<p>We apologize for any inconvenience.</p>
</article>
</body>
</html>
<?php
exit;
}
- In the begging of index.php add
include_once('maintenance.php');