在使用Yii2时,如果启用了美化的Url,则访问http://www.aaa.com ,不能直接显示http://www.aaa.com/site/index.html内容。 这时候需要配置rules
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'suffix' => ".html",
'rules' => [ '' => 'site/index', // 如果没有这里,则访问域名不能直接打开默认Action
]
]
当然,如果使用的默认控制器、动作不是site/index,那还要设置这里:
$config = [
'id' => 'basic',
//'defaultRoute'=>'site/index',
...