0
class TestController extends Controller {
function init() {
if(!(strtolower(yii::$app->requestedRoute) == "account/login" || empty(yii::$app->requestedRoute)))
{
if (false===$this->isLogin()) {
return $this->redirect('/login'); //it works, will redirect
}
} else {
if($this->isLogin()) {
return $this->redirect('/purchaser/manifest'); //not work, won't redirect
//echo $this->redirect('/purchaser/manifest'); //work
}
}
}
}
我重寫了控制器。當我嘗試過濾時,我發現這個問題。我很困惑,有什麼幫助?yii2在init中重定向是否工作?
謝謝你的回答,但我不得不使用「echo $ this-> redirect('/ purchaser/manifest')」。至少我知道原因。 –