1.修改/usr/local/testWeb/frontend/config/main.php文件为:
[
'components' => [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'suffix' => '.html',
'rules' => [
// ...
],
],
],
]
2./ect/nginx/nginx.conf,修改配置:
location / {
# root /usr/local/nginx/html;
root /usr/local/testWeb/frontend/web;
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
3.
本文介绍如何在Web应用中实现URL美化,包括修改main.php文件以启用URL美化功能,以及调整Nginx配置文件以正确解析并重定向URL请求。通过这些步骤,可以提升网站的用户体验。
1903

被折叠的 条评论
为什么被折叠?



