You are here:Home»KB»Web Design»eCommerce»Magento»How to put your magento site into maintainance mode
Saturday, 08 September 2012 18:42

How to put your magento site into maintainance mode

Written by

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.

just create a file in the root of your store called maintenance.flag

The only problem with the method above, 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);

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

Conversely

“Service Temporarily Unavailable” – disabling maintenance mode in Magento – maintenance.flag

If you’re seeing the “Service Temporarily Unavailable” screen when you attempt to load your Magento store (there’s a somewhat related thread here on magentocommerce.com), the most likely cause is you’ve made some updates to Magento recently, and the maintenance.flag file in your Magento root directory wasn’t successfully removed by the Magento Connect tool.

Fixing the Service Temporarily Unavailable error in Magento

Nice and simple fix for this one! Remove the maintenance.flag file in the root directory of your Magento installation.

This can be triggered by running updates or installations of extensions in Magento Connect; the file is removed on successful completion of the upgrade or installation, so if it fails for any reasons, you’ll see this screen.

Read 931 times Last modified on Tuesday, 12 May 2015 11:18