1

the user document has no information on this. And from what I've read, all you do is create a maintenance.flag file in order to kick the store into maintenance mode in the community edition. Well in Magento GO, you actually have a setting in the configurat ion menu. Why was this removed for CE??

I'd like to do a few things other than just use the general 503 page. For one, I want to be able to use a CMS page that I create, to be what the site shows when in this mode. I also need to be able to whitelist IP's.

The reason this is so important is because I need to apply this to my development site...so it will forever be in maintenance mode as it's what I use to test on a live server before transferring info to the actual site. Of course robots are blocked but that still will never stop people from going to the url and so if they do, I need them to see a custom page with my own info..not the default page. Any suggestions or help?

1

For your local or staging development site I would actually stick to leaving the site in the normal mode and then restricting users via ip through either changing your .htaccess or actually the server settings.

This will not only give you more control but will allow you to run the site "as live" without worrying about who can access this.

1

General Apache related solution. It is work on any website not only Magento based.

  1. Create maintenance.html with any text you want. You just may place even your logo here
  2. Edit .htaccess file and add the following code:
RewriteEngine on
# Point your IP here
RewriteCond %{REMOTE_ADDR} !^11\.11\.11\.11
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
# If you use logo in your maintenance.html
RewriteCond %{REQUEST_URI} !^/path/to/logo\.gif$
RewriteRule ^(.*)$ http://www.domain.com/maintenance.html [R=307,L]

Any web server solution (if you have nginx webserver without an ability to edit nginx.conf, etc)

  1. Create maintenance.php

<?php
    define("SITE_NAME","Enter Site Name");
    define("SITE_TITLE", "Site is down for maintenence - %s");
    // MAINTENANCE
    $conditions = array(
        array("REMOTE_ADDR" => "!^(11\.11\.11\.11)"), //your IP here
    );
    $rules = array(
        "^(.*)$"
    );

    $result = true;
    foreach ($conditions as $cond) {
        $serverVar= key($cond);
        $regexp = current($cond);
        $negate = false;
        if (substr($regexp, 0, 1) == "!") {
            $negate = true;
            $regexp = substr($regexp, 1);
        }

        if (!empty($_SERVER[$serverVar])) {
            $condResult = preg_match( '~'.$regexp.'~i', $_SERVER[$serverVar], $params );
            if ($negate) {
                $condResult = !$condResult;
            }
            $result &= $condResult;
        }
    }
    if ($result) {
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <title><?php echo printf(SITE_TITLE, SITE_NAME);?></title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <style>
            body { text-align: center; padding: 150px; }
            h2 { font-size: 30px; }
            body { font: 20px Helvetica, sans-serif; color: #333; }
            article { display: block; text-align: left; width: 650px; margin: 0 auto; }
            a { color: #dc8100; text-decoration: none; }
            a:hover { color: #333; text-decoration: none; }
            .blog {display: block; margin: 30px auto 0px auto; font-size: 30px; font-weight: bold; color: #f26c4f;}
    </style>
        </head>
        <body>

        <article>
            <h1 class="blog"><?php echo SITE_NAME;?></h1>
            <h2>Site is temporary unavailable.</h2>
            <p>We are currently performing scheduled maintenance. Site will back soon.</p>
            <p>We apologize for any inconvenience.</p>
        </article>
        </body>
    </html>
    <?php
    exit;
    }
  1. In the begging of index.php add
include_once('maintenance.php');
0

Well first to change the 503 error page you need to look at this link its pretty in depth. Second you want to look at your

.htaccess

check this page out on how to do it. Its pretty simple just follow the guides.

  • Ah, excellent! Thank you :) I hope the Magento team bring that option within configuration into the next version. It's literally the only e-commerce platform of the top 10 titles, that does not have such a huge importance of an option. – craven Aug 3 '14 at 2:20
0

Here is a simple way to put site on maintenance mode and keep it full functioning to whitelisted IPs. Add this code with your IP to index.php just after <?php in the next line

if ($_SERVER['REMOTE_ADDR'] != 'YOUR_IP_ADDRESS') {
    include_once dirname(__FILE__).'/errors/503.php';exit;
}

If you need several IP addresses, you can slightly modify it:

if (!in_array($_SERVER['REMOTE_ADDR'], array('YOUR_IP_ADDRESS1', 'YOUR_IP_ADDRESS2'))) {
    include_once dirname(__FILE__).'/errors/503.php';exit;
}

Maintenance page can't be a CMS page but it can be of custom design and content. Just replace code in errors/503.php file with custom page HTML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.