nginx访问页面中文乱码解决方案

 1、网页代码设置utf-8编码格式,内容参考如下:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>简体中文标题</title>
</head>
<body>
    <center>简体中文内容</center>
</body>
</html>

2、nginx服务端的nginx.conf设置utf-8编码格式。需要注意的是server层和访问路径location都要配置。 

server {
        listen       80;
        server_name  houzhigao.com;
        charset utf-8;
        location / {
            root   index;
            index  index.html index.htm;
        }
    }

3、修改了nginx的配置文件,需要重新加载一下nginx。

执行:

nginx -s reload

或执行:

/usr/local/nginx/sbin/nginx -s reload

4、最后访问测试:中文解析正常。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>