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

前端 未结 3 923
旧巷少年郎
旧巷少年郎 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

    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'));
    }
    

提交回复
热议问题