Reputation: 823
I need configure my Yii2 UrlManager
rules like this:
http://domain/site/action
to http://domain/action
http://domain/module/default
to http://domain/module
so far what I have done:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'<module:(!site)>' => '<module>/default',
'<action:\w+>' => 'site/<action>',
],
],
when I trying access module
it return 404. But when I remove '<action:\w+>' => 'site/<action>',
access module
again will show as module/default
page. So how to solve this?
Upvotes: 0
Views: 654
Reputation: 784
You can try this code
'<action:(about|contact)>' => 'site/<action>',
insted of this
'<action:\w+>' => 'site/<action>',
and it will not work then change sequence of rules
'rules' => [
'<action:\w+>' => 'site/<action>', <-----------it will be first
'<module:(!site)>' => '<module>/default',
],
Upvotes: 0