1、在\config\web.php中加入urlManager部分
'components' => [ 'urlManager' => [ 'showScriptName' => false, 'enablePrettyUrl' => true, ], 'request' => [
2、在nginx下修改配置
location / {
root C:\yourpath;
index index.html index.htm index.php;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
root C:\yourpath;
index index.html index.htm index.php;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
配置好以后重启nginx
之前访问url:localhost/index.php?r=site/about
配置好以后:http://localhost/site/about 就可以这样访问了。看着顺眼多了。