nginx - 为什么我不能在 nginx 中正常显示 CJK 字符?
问题描述
环境:Windows 10 + nginx/1.8.0。目录下的文件mysql
都是 UTF-8 编码,所有 HTML 文件都mysql
包含 <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;
}
}
}
mysql
我启动我的 nginx 服务器并在 Firefox 中打开目录:
所有 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/"
http://127.0.0.1/mysql/mysql日志.html
在我的 Firefox 中输入并单击。所有 CJK 字符均正确显示。
如何解决点击title in时跳转到包含乱码CJK字符的网页的问题127.0.0.1/mysql
?
经验证,对于相同的目录和文件,CJK 字符可以在nginx + Linux而不是nginx + Windows中正确显示。
解决方案
按照alibabacloud guide,我最好的猜测是您应该只使用charset utf-8
并且您还应该检查所有文件名是否为 UTF-8 格式或转换为 UTF-8 否则(仅文件名,而不是内容)。
推荐阅读
- python - 为什么创建模型后数据库中的外键为 NULL?
- node.js - 尝试需要模块时遇到问题 - Node.js
- spreadsheet - Google Sheet - 在 A 列中搜索“Cat”或“Dog”,然后返回 B 列相应范围的最大值
- .net-core - C# MongoDB 驱动程序通过过滤或任何聚合框架管道替换递归调用
- python - 如何使用 AES 模式 CBC 实现 HMAC 验证
- angular - 动态生成的嵌套 mat-tab-group 未按预期工作
- python - 如何在一个进程中引发异常并在另一个进程中捕获它?
- javascript - 我想在我的项目中添加 gif,我正在编译文件加载器。但我在控制台 Minified React 错误 #130 上收到错误消息
- arrays - VueJs 使用 push 在 LocalStorage 中插入数据数组
- javascript - 检查浏览器是否支持 unadjustedMovement