Reputation: 391
In web.php
I have following code:
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'calc' => 'site/calc',
),
],
And I want to allow users to access to example.com/calc
but not to example.com/site/calc
. How I can do it properly with less effort? By other words now works both options - "site/calc
" and "calc
" and I want to disable "site/calc
".
Upvotes: 4
Views: 467
Reputation: 196
Try to add enableStrictParsing to UrlManager configuration as follows
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'rules' => array(
'calc' => 'site/calc',
),
],
In this case if there's no rule matching the request then it's considered as bad one.
Upvotes: 1