ZF2段路由:只有最后一个元素

时间:2014-10-28 08:44:47

标签: php regex zend-framework zend-framework2 zend-framework-routing

我有这个分段路线:

'content' => array(
    'type'    => 'Segment',
    'options' => array(
        'route'    => '/:title{-}-:id',
        'constraints' => array(
            'title'         => '[a-zA-Z0-9_-]*',
            'id'            => '[0-9]+',
        ),
        'defaults' => array(
            'controller'    => 'content',
            'action'        => 'index',
        ),
    ),
),

它正确识别出这样的网址,“id = 20”:

http://example.com/blood-on-ice-20

但它也使用此网址识别“id = 20”:

http://example.com/timekeeper-20th-anniversary-box-12951

我该如何避免这种情况?

0 个答案:

没有答案