【发布时间】:2013-08-05 13:57:05
【问题描述】:
我在Zend Framework 2 的Module.php 中正确重定向有一些问题。 Iceweasel 浏览器显示此信息: “页面未正确重定向”。
我的代码很简单,但似乎会产生一些问题:
$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 会对上述消息做出反应?
【问题讨论】: