Apache Httpd 的 html 乱码问题

最近在对几个旧网站翻新时,发现这样一个问题:

原来的页面是使用 GBK,GB2312编码,当前的页面使用的是 UTF-8.

不管怎样设置 htnl 的 charset,用浏览器访问时,原来的页面一直乱码。浏览器不能识别页面指定的编码。

<meta http-equiv="Content-Type" content="text/html; charset=GBK" />

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

环境

CentOS release 6.7 (Final) 64bit

Apache httpd 2.2.15

问题的原因

由于apache httpd 的配置问题,默认是UTF-8,摘抄其中内容如下: /etc/httpd/conf/httpd.conf

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the 
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

解决办法

注释该行。

#AddDefaultCharset UTF-8

重启httpd服务器即可。

#service httpd restart


转载于:https://my.oschina.net/hyperichq/blog/668021

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值