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層設置字符集
}
}