TP5路由的位置导致错误

// 测试
'[js]'  => [
    ':id'   => ['test/test/js', ['method' => 'get'], ['id' => '\d+']],
    ':id/info'   => ['test/test/info', ['method' => 'get'], ['id' => '\d+']],
],
这一行的路由规则':id'   => ['test/test/js', ['method' => 'get'], ['id' => '\d+']]  会屏蔽下一行的规则,导致下一行的路由永远不生效
比如: www.test.com/54 正常生效
www.test.com/54/info  没生效,和www.test.com/54效果是一样的


可以换个位置即可
// 测试
'[js]'  => [
    ':id/info'   => ['test/test/info', ['method' => 'get'], ['id' => '\d+']],
    ':id'   => ['test/test/js', ['method' => 'get'], ['id' => '\d+']],
],

路由是一行一行匹配的

 

posted @ 2019-10-29 17:56  study_php_java_C++  阅读(429)  评论(0编辑  收藏  举报