当我登录后端管理面板时。它工作正常,但当我第一次访问链接(例如:site.com/backend/web/site/manage-country)时,它不会显示任何错误。如果我第二次访问同一个链接。它重定向到site.com并显示此错误。
异常'yii \ web \ ForbiddenHttpException',带有消息'你不是 允许执行此操作。'在 /home/kometonl/public_html/demo/vendor/yiisoft/yii2/filters/AccessControl.php:151
清除cookie后。我会恢复正常的网站。
后端/控制器/ SiteControllers.php
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'actions' => ['logout', 'index','manageCountry'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
后端/配置/ main.php
'urlManager'=> [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'site/manage-country' => 'site/managecountry',]
],
答案 0 :(得分:0)
改变您的行为
[
'actions' => ['logout', 'index','managecountry'],
'allow' => true,
'roles' => ['@'],
],
SiteController中的
public function actionManagecountry(){
echo 'hi';
}