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

location ^~ /translate/ {   //定位URL中translate文件夹下的静态文件

        if (!-e $request_filename){   //通过访问时添加后缀来隐藏URL中的后缀
           rewrite ^(.*)$ /$1.html last;
           break;
        }
        root /var/www/html;
        index index.html index.nginx-debian.html;
        try_files $uri $uri/ =404;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *