Lnmp under nginx Chinese file name or directory 404 cannot access the workaround

Source: Internet
Author: User

It seems that many people will still encounter the problem of Chinese garbled, Apache can use mod_encoding support Chinese directories and files,LnmpNginx does not need to install additional components to support the Chinese file name or Chinese directory, the following is the common CentOS, Debian, Ubuntu Linux distribution under the Setup method and may encounter problems:

You can do this before setting:locale to see if the display is en_US. UTF-8, which is normal, does not have to be set in the following steps. If the other encoding is displayed, you need to set it as follows.

Centos:

Edit the/etc/sysconfig/i18n file and modify the content to: (can use VI, nano or WINSCP graphics management software, according to personal taste choice)
Lang= "en_US. UTF-8 "
Sysfont= "Latarcyrheb-sun16"

Save, restart the system to take effect, or edit/etc/profile to add export lang= "en_US at the end of the file. UTF-8 "Port SSH client, reconnect will take effect.

Debian:

Apt-get install-y locales
Dpkg-reconfigure locales

The following dialog box appears after executing dpkg-reconfigure locales:

Use the DOWN ARROW keys to find the en_US. UTF-8 UTF-8, press space to select, then press ENTER.

Press the DOWN ARROW key again to select en_US. UTF-8, then press ENTER to confirm.
Reboot the system.

Ubuntu:

Edit the/etc/default/locale file, modify the content to (create one without words):
Lang= "en_US. UTF-8 "
Language= "En_us:en"
Save, then execute:locale-gen en_us en_US. UTF-8
Reboot the system.

Execution:locale to see if the display is en_US. UTF-8, if the error, please feedback in this article.

Follow the above steps to set up to support Chinese, you can upload Chinese files or Chinese directories.

Problems you may encounter:

If you use a tool such as WINSCP or FLASHFXP to upload to Utf-8, you can set the steps as follows:

WinSCP:

    1. Open WINSCP, select the session to log in from the login screen
    2. Click the "Edit" button next to
    3. Find the "Environment" item in the tree menu on the left and open it
    4. In the right, one entry is "file name UTF-8 encoding", select "on", and the setting is complete.

FlashFXP:

    1. Open FLASHFXP, click Sites, select Site Manager
    2. Click to select the site to login, on the right click on the "Options" tab, "character encoding" after the list box select UTF-8, set to complete.

If garbled characters are displayed under SSH clients such as putty or Xshell, it is also necessary to modify the character encoding to UTF-8.

Putty:

    1. Open putty, select default Settings in the login session interface
    2. Then click on the Left Tree menu "window", then "translation", the Chinese version of the words corresponding to "windows", "conversion"
    3. In the right side of the interface there is a "Remote character set:", the Chinese version is "assumed to receive data character set", select "UTF-8" in the drop-down list, set to complete.

Xshell:

    1. Open Xshell, right-click on the session list to log on to, select "Properties"
    2. In the click "Terminal", in the translation there is a encoding drop-down list box, select "UTF-8", set the complete, simple point of the setting method, directly point the above toolbar in the blue-green sphere, select "UTF-8".

Said so much, in fact, is a bit, coding consistent, code inconsistency will appear garbled.

If you do not change the encoding before uploading the file, the settings will still be garbled, it is recommended to re-upload the file. If no backup of the original file can be converted using the following command: Forf in ' LS *.html ', do mv $f ' ls $f |iconv-f gbk-t UTF-8 ';

Where *.html is the type of file to be converted, can also be changed to *.txt,*.rar is mainly to see what you are files, inside the GBK for the source file encoding type, if you do not know the source file encoding type can be executed:file-bi file name .

If you want to change in Windows, it is also possible that the EditPlus has the ability to batch modify the file encoding, other software may also have such features, you can study it yourself.

If it is a directory, there seems to be no way to convert it.

There is a problem, if it is HTML, such as Web files, if the original content is gb2312 or similar non-UTF-8 encoding, the first to change the page inside the charset to Charset=utf-8, and then convert the file encoding, otherwise the page will be garbled.

Lnmp under nginx Chinese file name or directory 404 cannot access the workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.