I need to put frontend of my site to maintenance mode. so I enabled maintenance flag by creating empty folder in the name maintenance.flag in the root folder. But when I do this, my backend panel is also getting locked under maintenance mode. I want to work in my back panel So someone kindly guide me to enable maintenance mode only at frontend.
2 Answers
To do this, open the index.php in root and add (remembering to edit the ‘allowed’
array to contain the IP’s you want to be able to access the site);
$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.
Next, search for this piece of code
if (file_exists($maintenanceFile)) {
and replace it with this:
if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
Simple. Now you can access the site (admin + front end), while others see its maintenance mode.
Source: http://inchoo.net/ecommerce/magento/maintenance-mode-in-magento/
Hope this make sense to you
I found the solution, We have to add
$url=(!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
before
$maintenanceFile = 'maintenance.flag';
in index.php