質問

I have added a param in config/main.php to determine if the site is offline or not. I've tried

Yii::createWebApplication($config)->run();
if(!Yii::app()->params['enabled'])
  die;

at the bottom of index.php file. but it doesn't die. Why?

役に立ちましたか?

解決

You should use CWebApplication::CatchAllRequest in your config

Refer : http://www.yiiframework.com/doc/api/1.1/CWebApplication#catchAllRequest-detail

You can specify a controller/route to show a maintenance page by changing your config array; You can have different config file for when the site is down for maintenance; and another one for when it is live your config file should look something like

return array(
 .... 
     'catchAllRequest'=>array(
          'offline/notice'
          'otherParams'=>'value',
      ),
 ....
),

You of course need to have an offline controller and notice action plus a notice view file;

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top