Apache编码修改

使用Apache 做了一个下载站,结果中文软件包显示全是乱码。可以通过IndexOptions Charset=GB2312解决。

 Alias charset 编码iso-8859-1

[root@zj-test ~]# curl -I http://www.darcul-zj.com/1
HTTP/1.1 301 Moved Permanently
Date: Fri, 21 Jan 2011 12:38:01 GMT
Server: Apache/2.2.3 (Red Hat)
Location: http://www.darcul-zj.com/1/
Connection: close
Content-Type: text/html; charset=iso-8859-1 

 主站编码GB2312

[root@zj-test ~]# curl -I http://www.darcul-zj.com/
HTTP/1.1 200 OK
Date: Fri, 21 Jan 2011 12:38:05 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Wed, 19 Jan 2011 13:51:03 GMT
ETag: "4d45e5-f-4ece5fc0"
Accept-Ranges: bytes
Content-Length: 15
Connection: close
Content-Type: text/html; charset=GB2312 

httpd.conf配置:

[root@zj-test ~]# cat /etc/httpd/conf/httpd.conf | grep AddDefaultCharset 
AddDefaultCharset GB2312 

 虚拟主机配置:

[root@zj-test ~]# tail -n 13 /etc/httpd/conf/httpd.conf

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot /var/www/webroot/web1/
    ServerName www.darcul-zj.com
Alias /1 "/var/www/webroot/web1/packge"
<Directory /var/www/webroot/web1>
    OPTIONs  Indexes FollowSymLinks
    IndexOptions Charset=GB2312
    AllowOverride None
</Directory>
</VirtualHost>

 重启Apache,中文正常显示。

通过htaccess实现请参考: http://alexpress.blog.163.com/blog/static/10718752008115798918/

你可能感兴趣的:(alias,utf-8,gb2312,apache编码,web乱码)