准确地说应该是GBK编码网页中文乱码(UTF8的正常)。

方法一:

编辑Apache配置文件:

vi /etc/httpd/conf/httpd.conf

修改AddDefaultCharset UTF-8为:

AddDefaultCharset Off

深入分析:

默认的AddDefaultCharset UTF-8将影响Apache输入HTTP应答头中的Content-Type字段中的charset值:

Content-Type: text/html; charset=utf-8

改为AddDefaultCharset Off后,Conten-Type字段的值将仅为:

Content-Type: text/html

方法二:

htaccess文件配置文档,Apache Module mod_autoindex(http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html#indexoptions),里面有FancyIndexing项目(其实之前都用过这个设置的IndexOptions NameWidth了),IndexOptions竟然也有一个关于编码的设置,Charset=character-set。

修改htaccess文件,加入

IndexOptions Charset=GB2312


标签: apache

添加新评论