Linux does not support Chinese urls and file names. In Internet Explorer, the URL is encoded in UTF-8 mode by default, and the request is sent to the server. When Chinese characters appear in the URL, the URL is encoded in UTF-8 mode and sent to the server. At this point, the server’s character set affects how the WEB decodes the URL.
Many times in NGINX and APACHE, the nature of the problem is whether the character set requested by the browser is the same as the character set on the server. When the inconsistency occurs, the server cannot find the requested path, resulting in a 404 NOT FOUND error. The solution can start from the following aspectsCopy the code
1, the server system character set
You can run the echo $LANG command on centos to query information. You can add it in vi /etc/profileCopy the code
export zh_CN.utf-8
export LANG=zh_CN.utf-8
Then restart the server to take effect
2, nginx conf file configuration character set
In/WWW/wdlinux/nginx/conf/nginx. Charset Settings in the conf.
The character set of the requested file path or filename.
Points 1 and 2 are easy to change, and point 3, to change the character set of the filename, requires the use of the tool convMV
Convmv can download it from http://j3e.de/linux/convmv,
Wget j3e. DE/Linux/convm…
CD convmv 1.14 make clean; make installCopy the code
Such as:
convmv -f gbk -t utf-8 thesis
The above indicates that the file names of all files under the Thesis are converted from GB2312 to UTF-8
Iconv can be used for character set conversion of file content
Install yum install convmv
Grammar:
Convmv [options] FILE (S)… DIRECTORY(S)
Main options:
-f ENCODING Specifies the ENCODING of the current file name, such as -f GBK. -t ENCODING Specifies the ENCODING to be converted. For example, -f utf-8 3, -r all file names in the recursive conversion directory 4, -list lists all supported encoding 5, -notest By default, only the conversion effect is printed.
Common parameters:
-r Recursively processes subfolders
– notest Indicates the actual operation. By default, no actual operation is performed on files
– List Displays all supported codes
— Unescap can do some escaping, such as changing %20 to a space
-i Interactive mode (queries each conversion to prevent misoperations)
How to use convMV:
Convmv -f source code -t New code [option] filename
Example: Recursively convert the file name encoding GBK under the Thesis directory (as shown below) to UTF-8:
convmv -f gbk -t utf-8 thesis