I used catchAll
route to my config
'catchAll' => ['site/page']
and it works fine.
But all request are going to this action, even that one that have a separate controller/action.
How can I map the routing to match the controller/action at first, and if corresponding controller/action doesn't not exists, then fallback to catch all route?
This config does what you want:
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'contact' => 'site/contact',
'/' => 'page/view',
------> HERE
'/<url:[a-zA-Z0-9-]+>' => 'site/page',
],
],
You should probably modify the rule to catch more chars. I used this, because I know my routes.
The catchAll
should be used when you want to put the website into maintenance mode. The error catch can also be used in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With