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!