nginx上的静态网页在访问的时候没有html后缀

现有日课的程序是html结尾,而在VPS部署之后,想要显示没有html。服务器可能会因此出现404错误,为了解决这个问题,需要在nginx上进行设置,代码如下:

//通过访问时添加后缀来隐藏URL中的后缀
location / {
if (!-e $request_filename){
   rewrite ^(.*)$ /$1.html last;
   break;
 }
index index.php index.html index.htm default.php default.htm default.html;
//指定目录
root /www/wwwroot/xxxxxxxxxxx;
}

解决方案来自:https://coding.f10.org/VPS相关/nginx上的静态网页在访问的时候没有html后缀/

All rights reserved
Except where otherwise noted, content on this page is copyrighted.