Home
/
Other Applications
/
How to enable the Maintenance mode in Magento 1.x?

How to enable the Maintenance mode in Magento 1.x?

To put a Magento site in maintenance mode, you need to create empty maintenance.flag file and upload it to the root folder of your site. Note, that once you enable the maintenance mode, even if logged as admin, you won’t be able to access the front end of the site. You will need to modify the index.php file in the Magento root folder to grant access to certain IP addresses that can load the site. To do this, open the index.php file and add this code on line 49:

$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('69.65.23.100','2.2.2.2');

In the $allowed = array(‘69.65.23.100′,’2.2.2.2′); you should specify a list of IPs that will have access to your site.

Next, search for this piece of code:

if (file_exists($maintenanceFile)) {

and replace it with this:

if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {

The modified index.php file should look like this:

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('69.65.23.100','2.2.2.2');
 
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename." was not found";
    }
    exit;
}
 
if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

If you want to display more information than simply a maintenance mode text, you can edit the 503.phtml file located under the Errors/Default folder.

Share This Article