Monday, October 7, 2013

How to activate "Maintenance Mode" in #Magento


You need to hide or block the access to your Magento web site, but that block need to be conditional for only some IP address.


Since the version 1.4 is possible to activate a Maintenance Mode just creating a file called maintenance.flag in your root directory but that is not really useful at all.

You need a workaround, to allow the access to some IP adress:
1. Open index.php in the root .
2. Look for that line:
    if (file_exists($maintenanceFile)) {
3. Replace it with that one:
    if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
4. Paste next code just above the line before:
    $ip = $_SERVER['REMOTE_ADDR'];
    $allowed = array('','');
5. In the $allowed array you have to included the IP allowed to access to your website.

1 comment: