Magento: More Handy Maintenance Mode

Magento Community ships with an easy way to put your entire site into maintenance mode.  This allows you to display a message to your users, without allowing them to browse the core of the site (pages, products, place orders, etc…).  This comes in handy when you need to perform big updates to your site or to upgrade the version of Magento.  One down side to the stock maintenance mode feature is that it locks all users out, including you.  It would be very helpful if you could lock all users out, but still allow you to browse the site yourself to test after updates are applied, etc…  One very easy addition to the main index.php file in your Magento installation will allow you to do just that.  Adding the code below and your IP address(es) will allow you and any others your specify to view the site, while all other users will see your maintenance page.

Look for this code block:

if (fileexists($maintenanceFile) { includeonce dirname(FILE) . '/errors/503.php'; exit; }

And replace it with the following (adding your IP address to the $ip variable:

$currentIP = $SERVER['REMOTEADDR']; $allowedList = array(''); if (fileexists($maintenanceFile) && !inarray($currentIP, $allowedList)) { include_once dirname(FILE) . '/errors/503.php'; exit; }

You might enjoy:

Next post No more posts


comments powered by Disqus