Magento 1.x – Put Magento in maintenance mode and allow it for certain ips
This tutorial explains how to put your Magento online store in maintenance mode so your visitors know that you are working on your website.
To put a Magento site in maintenance mode, you need to create an empty maintenance.flag file and upload it to the root folder of your site.
1 2 |
cd <root> touch maintenance.flag |
After that your web site will look like this:
Note: Once you enable the maintenance mode, even if logged as admin, you won’t be able to access to the front end of the site.
If you want to allow certain ip addresses, you will need to change your index.php file in your root directory.
Look the following line
1 |
if (!file_exists($mageFilename)) |
And change it with the following code:
1 2 3 4 |
$ip = $_SERVER['REMOTE_ADDR']; $allowed = array('1.1.1.1','2.2.2.2'); // these are the IP's that are allowed to view the site. if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) { |
After saving the file, you should be able to access the site with those ip addresses.