Tuesday, 31 December 2013

Put magento on maintenance mode and it open only on your ip








Today I am going to explain you how to put magento on maintenance mode. That maintenance mode will show to all other user user beside you. So can can work on a live environment if there is any issue.
Some time we all face a problem that something is not working on live environment while it is working on staging. So we have to test it on live environment but it is more difficult to put echo/ die on live site.
you can you do your work by using these steps so only you are able to open site while other see site is under maintenance mode.
Step 1 : put a file on your root with the name “maintenance.flag”
Step 2 : open you index file and find the code
if (file_exists($maintenanceFile) ) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}
Now update the code with that code
$ip = $_SERVER['REMOTE_ADDR']; // you can check your ip by http://who.is/
if (file_exists($maintenanceFile) && $ip != “your ip address” ) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}