在使用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 ] ]
Of course, if the default controller and action used are not site/index, then you need to set it here:
$config = [ 'id' => 'basic', //'defaultRoute'=>'site/index', ...
The above introduces the setting method of defaultAction in Yii2 when setting enablePrettyUrl, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.