dsfsfs 发表于 2018-11-26 13:43:15

Apache编码修改

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



# 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



# 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配置:



# cat /etc/httpd/conf/httpd.conf | grep AddDefaultCharset
AddDefaultCharset GB2312

  虚拟主机配置:
  # tail -n 13 /etc/httpd/conf/httpd.conf
  NameVirtualHost *:80

    DocumentRoot /var/www/webroot/web1/
    ServerName www.darcul-zj.com
Alias /1 "/var/www/webroot/web1/packge"

    OPTIONsIndexes FollowSymLinks
    IndexOptions Charset=GB2312
    AllowOverride None


  重启Apache,中文正常显示。
  通过htaccess实现请参考: http://alexpress.blog.163.com/blog/static/10718752008115798918/



页: [1]
查看完整版本: Apache编码修改