Apache 默认字符集不起作用

Apache 默认字符集不起作用

我正在尝试将默认字符集设置为 ISO-8859-1,因此我在 httpd.conf 中添加了下面的行。

AddDefaultCharset ISO-8859-9

当我使用以下方式查询时我可以看到这个值

root@server [/]# curl -A "Mozilla/4.0" http://localhost -I
HTTP/1.1 200 OK
Date: Mon, 10 Sep 2012 22:28:48 GMT
Server: Apache
Last-Modified: Tue, 21 Aug 2012 21:17:25 GMT
Accept-Ranges: bytes
Content-Length: 111
Content-Type: text/html; charset=ISO-8859-1

但是,我无法获得虚拟主机的相同结果,并且没有任何其他字符集的附加定义。

root@server [/]# file temp.php
temp.php: ISO-8859 text

root@server [/]# cat temp.php    
Cesária Évora

root@server [/]# curl -A "Mozilla/4.0" http://somedomain/temp.php -I
HTTP/1.1 200 OK
Date: Mon, 10 Sep 2012 22:28:31 GMT
Server: Apache
Content-Type: text/html; charset=utf-8

你有什么想法吗?如果你有线索,请告诉我。

谢谢。

答案1

charsetPHP中的属性由Content-Type处理php.ini

添加default_charset = iso-8859-1到您的 php.ini 或ini_set( "default_charset", "iso-8859-1" )在您的 中使用temp.phphttp://www.php.net/ini.core#ini.default-charset

相关内容