我的应用程序中存在路由问题。
$this->redirect('someone', array('controller' => 'account', 'action' => 'settings'));
它总是重定向到app.dev/someone与数组中的内容无关。
我发现问题出在 TreeRouteStack.php
的汇编方法中TreeRouteStack.php:347
$path = $this->baseUrl . $route->assemble(array_merge($this->defaultParams, $params), $options);
我在这行之前试过“死”来测试$ params - 一切都好。因此,在上方的代码之前die(implode(',',$params));
返回
帐户,设置
但在此echo $path
返回
/有人
而不是
/有人/帐户/设置
哪里可能有问题?我正在使用ZF2 2.2.2
答案 0 :(得分:1)
使用
$this->redirect()->toRoute(
'someone',
array('controller' => 'account', 'action' => 'settings')
);
而不是
$this->redirect(
'someone',
array('controller' => 'account', 'action' => 'settings')
);
请查看zf2文档中的Redirect Plugin