Answer the question
In order to leave comments, you need to log in
How to configure urlManager in Yii2 to work with modules?
There is a Product module. It contains a Backend controller for editing catalog products. Also in the app/controllers folder there is a ProductController controller with an actionIndex to display products. When I go to site.ru/product/index, I get 404. I realized that Yii is trying to find the Index controller in the Product module.
How to configure UrlManager (CNC) so that it would first search for controllers in the controllers folder, and only then climb into the modules?
"As before" doesn't help.
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
Answer the question
In order to leave comments, you need to log in
PrettyUrl specified? Some kind of suffix, hiding the script display?
Try this:
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => false,
'showScriptName' => false,
'rules' => [
'<controller>/<action>' => '<controller>/<action>',
'<module>/<controller>/<action>' => '<module>/<controller>/<action>',
],
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question