环境: Windows 10 + nginx/1.8.0。mysql目录下的所有文件都是UTF-8编码,mysql目录下的所有HTML文件都包含 <meta charset="utf-8" />
。
我用于文件 nginx.conf 的配置文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
charset gbk,utf-8;
source_charset gbk,utf-8;
autoindex on;
location / {
root d:/mydoc/build/html;
index index.html index.htm;
charset gbk,utf-8;
source_charset gbk,utf-8;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
我启动了nginx服务器并在Firefox中打开了
mysql
目录:
所有CJK字符都正确显示。现在点击第三个标题——mysql日志.html
:
显示文件error.log以查看发生了什么:2020/12/05 22:41:19 [error] 11252#11076: *8 CreateFile() "d:/mydoc/build/html/mysql/mysql日志.html" failed
(2: The system cannot find the file specified),
client: 127.0.0.1, server: localhost, request:
"GET /mysql/mysql%C8%D5%D6%BE.html HTTP/1.1", host: "127.0.0.1", referrer: "http://127.0.0.1/mysql/"
在我的Firefox中输入http://127.0.0.1/mysql/mysql日志.html
并点击。所有CJK字符都正确显示。
当单击127.0.0.1/mysql
标题时,它跳转到包含乱码CJK字符的网页。 如何解决此问题?
验证了相同目录和文件在nginx + Linux中可以正确显示CJK字符,但在nginx + Windows中却不能。