It is not recommended that you set the access permission of the error page. This will give another prompt message that does not have access to the error page when the user without permission has an error. The prompt is also not friendly.
If your goal is to display different levels of error pages for different ips, you can override the \\yii\\web\\ErrorAction to display different error pages for different privileged users, for example:
class MyErrorAction extends \yii\web\ErrorAction {
public function run()
{
if ('ip1' === \Yii::$app->request->userIP) {
return $this->renderHtml1();
}
if ('ip2' === \Yii::$app->request->userIP) {
return $this->renderHtml2();
}
return $this->renderDefaultHtml();
}
}
Then in the project's configuration file, configure the errorHandler's errorAction as your MyErrorAction, for example:
[
'components' => [
'errorHandler' => [
'errorAction' => MyErrorAction::class
],
],
]
Or you can override the \\yii\\web\\ErrorHandle::renderException() method to control the content of the presentation and configure errorHandle in the configuration file as your MyErrorHandler
This answer is translated from Google Translate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.