是否有这样做Zend框架2以下一个更好的解决方案:Zend框架2:多个路由到一个动作
我需要这两个网址转到一个动作 - 帮助/节/ 5和帮助/节。 ?PHP的ID = 5
我觉得这种方式太复杂了:
'helpSection' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/help/section/:id',
'defaults' => array(
'controller' => 'Application\Controller\Help',
'action' => 'section',
),
),
),
'helpSection2' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/help/section.php',
'defaults' => array(
'controller' => 'Application\Controller\Help',
'action' => 'section',
),
),
'child_routes' => array(
'query' => array(
'type' => 'Zend\Mvc\Router\Http\Query',
'options' => array(
'defaults' => array(
'id' => ':id'
)
)
),
),
),
你可以送花儿给人使用重写作为替代方法,并将这些内容保留在代码库之外。 很简单,重写带有扩展名(.php)的url到不带扩展名的url。 – Andrew 2013-03-14 13:59:09