Solution to Apache forced UTF-8 garbled in CentOS

Source: Internet
Author: User
Tags vps

Solution to Apache forced UTF-8 garbled in CentOS

Today, I purchased xen vps in PhotonVPS for my own use. The weak ones despise BurstNet's VPS, and I bought 19.95-knife, GB of traffic VPS, even though I still cannot accept a small number of download requests, my VPS is always disconnected. It's okay when I stop downloading ...... You have already asked BurstNet to cancel this VPS. This attempt to use PhotonVPS is also the first time to select the XEN architecture VPS. What will happen? It will take some time.

After selecting CentOS as the system step by step, I put the original webpage for testing. The previous webpage is in gb2312 encoding format. Each page has an HTML meta tag, indicating that this page uses gb2312 encoding (the code that comes with DW ). The results are garbled in the Firefox, IE, and Opera browsers. This is so strange! Clearly, the encoding in my browser is "automatically selected". In principle, the browser should read the meta tag of the HTML page and display the webpage according to the GB2312 encoding, but these browsers are without exception automatically selected UTF-8! Check the source code of the webpage. The HTML meta header is still marked with charset = gb2312, and does not change to UTF-8. Strange, is it CentOS Apache forced to change the Web code into a UTF-8?

With such a mentality, I ran to the search engine for a query. Hey, this is really the case. By default, CentOS provided by some VPS enables the ability to forcibly convert Page code to a UTF-8. Once this function is enabled, regardless of the charset in the original meta tag in HTML, the browser will be rendered in the form of UTF-8, resulting in garbled production.

It is easy to understand the cause. This is caused by an Apache parameter "AddDefaultCharset. Let's change the Apache configuration file to OFF.

Input:

# Vim/etc/httpd/conf/httpd. conf

Find the original

Adddefacharcharset UTF-8

Change it

Adddefacharcharset OFF

After you enter wq to save and exit vim, use the reload command or restart Apache to take effect. Here I chose to restart Apache:

#/Etc/init. d/httpd restart

Go to the browser and browse the webpage. Everything is normal and the problem is solved!

Related Article

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.