CakePHP 2.1.0: How to Create “Down for Maintenance” Page

前端 未结 3 916
旧巷少年郎
旧巷少年郎 2021-02-10 19:03

I\'m trying to implement something like Mark Story\'s \"Down for Maintenance\" page using CakePHP 2.1.0. I\'m pretty close to achieving this, but I\'m running into two issues th

相关标签:
3条回答
  • 2021-02-10 19:25

    here is a quick and dirty maintenance page for cakephp

    in public index.php

    define('MAINTENANCE', 0); 
    if(MAINTENANCE > 0 && $_SERVER['REMOTE_ADDR'] !='188.YOUR.IP.HERE')
    {
    require('maintenance.php'); die(); 
    }
    

    Then just change MAINTENANCE = 1 when you want to take your site down and it will still be viewable from your home/office.

    BONUS: Works with all versions of cake!

    0 讨论(0)
  • 2021-02-10 19:25

    A more elegant way would be to add a route overriding any other one at the very top of routes.php:

    //Uncomment to set the site to "under construction"
    Router::connect('/*', array('controller' => 'pages', 'action' => 'underConstruction'));
    
    //any other route should be underneath 
    

    If you want to add any condition you can also do it here:

    define('MAINTENANCE', 0); 
    if(MAINTENANCE > 0 && $_SERVER['REMOTE_ADDR'] !='188.YOUR.IP.HERE')
        Router::connect('/*', array('controller' => 'pages', 'action' => 'underConstruction'));
    }
    
    0 讨论(0)
  • 2021-02-10 19:39

    We'll need to create a custom Dispatch Filter,CakePHP has you covered. check below link

    http://josediazgonzalez.com/2013/12/13/simple-application-maintenance-mode/

    0 讨论(0)
提交回复
热议问题