Nginx静态html出现中文乱码
配置完reload一下nginx,实在不行都配置一下
1.在html页面中加入meta标签
网页代码设置utf-8编码格式
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
2.在nginx.conf设置utf-8编码格式
server层配置 或者 server层和访问路径location都要配置
server {
listen 81;
set $root F:/Develop/nginx-1.14.0/html;
root $root;
server_name localhost;
access_log logs/host.access.log main;
index index.html index.php;
# server层设置字符集
charset utf-8;
location / {
root html;
index index.html index.htm;
charset utf-8; # location层设置字符集
}
}