【问题标题】:zend framework 3 routing conflictzend framework 3 路由冲突
【发布时间】:2018-03-29 06:35:30
【问题描述】:

当我们在 url 中传递故事标题时,我在创建详细信息页面的路由时遇到问题,它与我们的类别 url 路由冲突。所以我需要在 url 的末尾验证 {-storyid}。

示例网址:

http://localhost.tank.com/hindi/any-one-can-dance-on-table-before-me-1756838

http://localhost.tank.com/hindi/{类别}

【问题讨论】:

  • 快线对吧?

标签: routing zend-framework3


【解决方案1】:

在 Zend Framework 2+ 中,您可以为您的路线添加优先级。更高的优先级意味着,您的路线将在其他人之前被处理。你也可以给一个否定的优先级。

module.config.php 中的路由需要优先级键,如下所示:

        'myroute' => [
            'priority' => 10,  // <-- route priority
            'type' => Segment::class,
            'options' => [
                'route' => '/hindi[:/category]',
                'constraints' => [
                    'category' => '[a-zA-Z][a-zA-Z0-9-]*',
                ],
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action' => 'index',
                ],
            ],
        ],

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多