Question

When i first started using Magento and I first made a backup, i ticked the put website into maintenance mode button. Once this was done when i tried to visit my site i was given a 503 error ( i think ). I found that this was due to magento creating a maintenance.flag file.

Iv come to understand that this is used to stop people accessing your site when you are updating things or backing up.

my question is this . . .

Is it possible to use a maintenance.flag file to block people from visiting your site while your physically updating and checking. I have 2 servers a test and a live server. the live server uses SSL and is much faster than the free testing server that i have. Currently I'm developing changes on the test server and then uploading to the live server once I know it al works and looks ok.

Since we applied the SSL to the live server. certain things are (or are not) happening when i do updates. I'm wondering if i can temporarily block access to my site while i check my updates then allow people back on.

the maintenance.flag file blocks me out of my site as well so as far as I can understand what I'm wanting to do is not possible.

Any Help appreciated

Was it helpful?

Solution

Yes, it's possible to set Maintenance Flag and then have your index.php check for a set of addresses that are let through while serving everyone else a 503 page. Only those systems will be allowed admin and public access while maintenance.flag is set. Find the section in index.php and make some modifications. I use the following on Magento 1.4.2.0, check to make sure 1.7 uses the same mechanism in index.php:

$maintenanceFile = 'maintenance.flag';
$ip = $_SERVER['REMOTE_ADDR'];

/***************
 * IP's allowed in maintenance.
 * Use publicly visible IP addresses on LIVE, local if on DEV
 ***************/

$allowed = array('10.0.0.100','10.0.0.101','10.0.0.20');

if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
    $basePath = dirname($_SERVER['PHP_SELF']);
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

OTHER TIPS

Store Maintenance : http://www.magentocommerce.com/magento-connect/store-maintenance.html

This extension will take care of your needs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top