Thursday, November 21, 2024

Nginx下使用中文URL和中文目录路径

一、确定你的Linux系统是UTF编码,Root登录SSH:

env|grep LANG
LANG=en_US.UTF-8

二、NGINX配置文件里默认编码设置为utf-8

server
{
listen 80;
server_name .inginx.com ;
index index.html index.htm index.php;
root /usr/local/nginx/html/inginx.com;
charset utf-8;
}

三、如果使用putty
windows –> translation –>UTF-8

mkdir 中文目录名
echo ‘中文目录名’ > 中文目录名/中国.html

四、如果是用securecrt 上传文件,请选择 回话–>外观–UTF-8
如果是FTP软件也将默认编码设置为TUF-8

五、如果上传的文件名出现乱码显示
执行

for f in `ls *.html` ; do mv $f `ls $f|iconv -f GBK -t UTF-8`; done

完毕。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.