1 首先要在yii框架里加上配置文件 main.php
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
],
],
2 在者就是在 Nginx,Apache(根据自己使用的服务器)上配置文件中 加上下面的配置项
location / {
try_files $uri $uri/ /index.php?$args;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php;
}
}
3 重启 Nginx或者Apache 重启就好!