put RBAC and if not enough rights left the page with the error number. How to make so what if the error 403 that was redirect on the page with an input? I tried to do something like right in the view.

if ($this->exception==403) Yii->app-response->redirect 

Any suggestions?

    1 answer 1

    Firstly, if you have Yii2, then the redirect function is incorrect.

    Secondly, you can catch an exception in this way ( In View - View ):

     use yii\helpers\Url; if (Yii::$app->response->getStatusCode() == 403) { return Yii::$app->response->redirect(Url::to(['home/index'])); } 

    You can also handle the error in the controller in this way:

     use yii\helpers\Url; if (Yii::$app->response->getStatusCode() == 403) { return $this->redirect(Url::to(['home/index'])); } 

    Where Home - Controller, Index - Action