How to put your magento site into maintainance mode

Web hosting, SEO, etc... related
Post Reply
User avatar
Nipuna
Moderator
Moderator
Posts: 2729
Joined: Mon Jan 04, 2010 8:02 pm
Location: Deraniyagala,SRI LANKA

How to put your magento site into maintainance mode

Post by Nipuna » Mon Nov 14, 2011 11:52 pm

Magento 1.4+ includes a nice feature that allowed you to throw the store into “maintenance mode” if you need to do/work or make changes. Which is great, freeze people out of the store while you work or make changes. The only problem with this, is it also freezes YOU out of the store so you can’t make the changes you need to. So here is a little bit of code, that allows you and other you set to work on the site while everyone else sees its maintenance mode.

All we need to do it edit 3 lines.

Open: index.php in root and above line 57 add (remembering to edit the ‘allowed’ array to contain the IP’s you want to be able to access the site);

Code: Select all

$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.

then change the line
if (file_exists($maintenanceFile)) {
to
if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
Simple. Now you can access the site, while others see its maintenance mode.

Or you can install this extension for free to work easily. http://www.magentocommerce.com/magento- ... -artson.it
Post Reply

Return to “Web Related”