轴承的精度等级标注:apache index dirctory乱码问题 - newman0708的专栏 - CSDNBlog

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 00:57:40
apache 的网页内容显示是乱码

非常感觉下面各位的回答,
http://forum.ubuntu.org.cn/
yaoms,etcte,HuntXu,sevk,shellex

http://linux.chinaunix.net/
maitr ,zengkun_2008 ,swordfish.cn ,飞哥2005 ,一路征程一路笑 ,cnjnhu



我的apache 是Apache/2.2.3。

apache 的网页内容显示是乱码,字符编码无法被浏览器正确识别呢,一定要我自己手动去浏览器里设置一下UTF-8,这个页面才正常显示了,刷新页面后就又是乱码了。我指的是apache自动产生的目录索引(Index of 页面),如图




我改的是/etc/apache2/apache2.conf,

1.注释掉AddDefaultCharset一行也没用,和原来 一样还是乱码。
2.改成AddDefaultCharset off 或是 AddDefaultCharset GB2312 也是一样的,总是apache自动默认的ISO-8859-1,依然是乱码.
3.再改成AddDefaultCharset UTF-8,也没有用,还是乱码。
每次改完,都分别重启apache。
4.在该文件中加入下面的两句
AddDefaultCharset GB2312
DefaultLanguage GB2312
还是乱码,没有用。

应该没改错文件呀,

后来发现,配置文件里的 那个 AddDefaultCharset 影响不到 apache 的 Index of 页面。

随便怎么改,查看到的http头,都是如下,字符编码总是charset=ISO-8859-1
例如 wget -S http://172.26.29.82

newman0708@newman0708-desktop:~$ wget -S http://172.26.29.82
--08:51:07--  http://172.26.29.82/
           => `index.html‘
Connecting to 172.26.29.82:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Thu, 28 Aug 2008 00:51:07 GMT
  Server: Apache/2.2.3 (Ubuntu) mod_jk/1.2.18 mod_python/3.2.10 Python/2.5.1 PHP/5.2.1
  Content-Length: 1330
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/html;
charset=ISO-8859-1
Length: 1,330 (1.3K) [text/html]

100%[====================================>] 1,330         --.--K/s             

08:51:07 (63.21 MB/s) - `index.html‘ saved [1330/1330]



我在windows下访问也是一样乱码,安装中文包是没有用,肯定问题出在apache的设置上。




得到http://linux.chinaunix.net/论坛上maitr 的提示,问题就解决了。

在/etc/apache2/apache2.conf尾部添加下面内容,就可以解决。


IndexOptions Charset=utf-8
Options Indexes FollowSymLinks

AllowOverride All

Order allow,deny
Allow from all



然后再用wget -S http://172.26.29.82查看http头,

newman0708@newman0708-desktop:~$ wget -S http://172.26.29.82
--08:51:07--  http://172.26.29.82/
           => `index.html‘
Connecting to 172.26.29.82:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Thu, 28 Aug 2008 00:51:07 GMT
  Server: Apache/2.2.3 (Ubuntu) mod_jk/1.2.18 mod_python/3.2.10 Python/2.5.1 PHP/5.2.1
  Content-Length: 1330
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/html;
charset=utf-8
Length: 1,330 (1.3K) [text/html]

100%[====================================>] 1,330         --.--K/s             

08:51:07 (63.21 MB/s) - `index.html‘ saved [1330/1330]

如图,



现在就正常了,不用再受apache乱码的气了,再次感谢回答过我这个问题的每一位。

在我问这个问题时,也有很多人有这样问题,希望能早点解决,所以我把帖子的内容整理一下,方便有类似问题的人。