1
我在web.php這條路線的規則:Yii2 - denyCallback好好嘗試一下正常工作
'my-stokkee/buy-credits' => 'user/buycredits',
和訪問規則:
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'ruleConfig' => [
'class' => AccessRules::className(),
],
'denyCallback' => function ($rule, $action) {
$this->redirect('login');
},
'rules' => [
[
'actions' => ['signup', 'create', 'reset-password'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['index', 'view', 'update', 'changepassword', 'buyaccount', 'buycredits', 'to-usd'],
'allow' => true,
'roles' => ['@'],
],
[
'actions' => ['manage'],
'allow' => true,
'roles' => ['admin'],
],
],
],
];
}
而不是重定向到登錄 ,它將重定向到my-stokkee/login。任何想法發生了什麼?
這是行得通的。謝謝:) – Sasha
Bah。你打了我3分鐘。 +1雖然。 – topher