【发布时间】:2013-09-07 11:21:51
【问题描述】:
我有一个带有索引操作的控制器,我在其中使用重定向路由:
$this->redirect()->toRoute('dummy-route')->setStatusCode('301');
这适用于我的本地开发机器,但是一旦我将它部署到暂存重定向就不再起作用了。 我设置了一个 header('Location: ') 只是为了查看重定向是否正常工作并且它是否按预期工作。
什么会导致 zf2 重定向无法在第二台机器上工作?
@noobie-php 是的,这是代码:
public function indexAction()
{
$this->redirect()->toRoute('base-calculator')->setStatusCode('301');
exit;
}
还有路线:
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
'base-calculator' => array(
'type' => 'Segment',
'options' => array(
'route' => '/calculate[/:criteriaFirst][/:criteriaSecond]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'calculator',
),
),
)
【问题讨论】:
-
你介意发布路线和动作
标签: php redirect zend-framework2