// 以下以basic版本为例
1.修改config/web.php
'components' => [
#code ...
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],#code ...
]
2.在和入口文件相同目录下加入.htaccess文件
.htaccess内容:
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php