backend/config/main.php
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'enableStrictParsing' => false, 'suffix' => '.html', 'rules' => [ '<controller:w+>/<id:d+>' => '<controller>/view', ], ],
如果在web文件夹下增加一个.htaccess文件,配置如下:
Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php