0
我在Module.php中的Zend Framework 2中正確重定向時遇到了一些問題。 Iceweasel瀏覽器顯示以下信息: 「頁面未正確重定向」。Zend Framework 2模塊重定向頁面沒有正確重定向
我的代碼很簡單,但似乎也產生一些問題:
$eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_DISPATCH, function ($e) {
$auth = new AuthenticationService();
if (!$auth->hasIdentity()) {
$url = $e->getRouter()->assemble(array(), array('name' => 'login'));
$response = $e->getResponse();
$response->getHeaders()->addHeaderLine('Location', $url);
$response->setStatusCode(302);
$response->sendHeaders();
return $response;
}
});
任何人都可以給我一些ZF2尖爲什麼Iceweasel與上述消息作出反應?
你是對的,我忘了添加路線條件。 謝謝你的回答。 –