Custom URL Rules with Modules in Yii2

I look around, but did not find what I needed. Basically, I have several small modules that have only DefaultController and several larger ones with several controllers. My rules for small modules work fine, but those of large modules will not. Here are my rules:

'<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>'

The first two rules work fine, allowing me to access: http://host/news/createand the route to news/default/create.

The last two should do the following: http://host/posts/categorywhich should go to posts/category/index and also http://host/posts/category/createthat should go toposts/category/create

They do not seem to work, unfortunately. Any suggestions?

+4
source share
1

, , .

: w+/w+: Yii, , catch-all .

, , - - :

'<module:news>/<action:\w+>' => '<module>/default/<action>',
'<module:news>/<action:\w+>/<id:\d+>' => '<module>/default/<action>',
'<module:posts>/<controller:\w+>' => '<module>/<controller>/index',
'<module:posts>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>'

, .

+5

All Articles