main.php中’components'=>[] 中添加如下代码:
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false,//隐藏index.php // 'enableStrictParsing' => false, 'suffix' => '.html',//后缀,如果设置了此项,那么浏览器地址栏就必须带上.html后缀,否则会报404错误 'rules' => [ ], ],
添加.htaccess文件:
Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php