我改的是/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
newman0708@newman0708-desktop:~$ wget -S
--08:51:07-- /
=> `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-1Length: 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的设置上。
得到论坛上maitr 的提示,问题就解决了。
在/etc/apache2/apache2.conf尾部添加下面内容,就可以解决。
IndexOptions Charset=utf-8
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
然后再用wget -S 查看http头,
newman0708@newman0708-desktop:~$ wget -S
--08:51:07-- /
=> `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-8Length: 1,330 (1.3K) [text/html]
100%[====================================>] 1,330 --.--K/s
08:51:07 (63.21 MB/s) - `index.html' saved [1330/1330]