【发布时间】:2015-02-08 18:15:15
【问题描述】:
我一直在四处寻找,但没有找到我需要的东西。基本上,我有一些只有 DefaultController 的小模块和一些带有多个控制器的大模块。 我的小模块规则工作正常,但大模块的规则不行。这是我的规则:
'<module:\w+>/<action:\w+>' => '<module>/default/<action>',
'<module:\w+>/<action:\w+>/<id:\d+>' => '<module>/default/<action>',
'<module:\w+>/<controller:\w+>' => '<module>/<controller>/index',
'<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>'
前两条规则运行良好,允许我访问:
http://host/news/create 和路由到news/default/create。
最后两个应该执行以下操作:
http://host/posts/category 应该路由到 posts/category/index
和
http://host/posts/category/create 应该路由到 posts/category/create
遗憾的是,它们似乎不起作用。有什么建议吗?
【问题讨论】:
标签: php url-routing yii2