[英]apache server serves some pages with upper case UTF-8 and others with lower case utf-8 charset header
I am using MAMP
to host php
pages over and apache server
. 我正在使用
MAMP
通过apache server
托管php
页面。 In my root directory I have a .htaccess
file to do some rewrites and other things including adding charsets to the headers of certain files like so: 在我的根目录中,我有一个
.htaccess
文件来进行一些重写和其他操作,包括将字符集添加到某些文件的标头中,如下所示:
AddCharset UTF-8 .css .js
Now this code is working fine but I have an issue that is really annoying. 现在这段代码可以正常工作,但我遇到的问题确实令人讨厌。
The page test.php
returns a bunch of html which contains links to some .css
and .js
files. 页面
test.php
返回一堆html,其中包含指向某些.css
和.js
文件的链接。 Now when I call up the test.php
file over my browser it returns the following in the response header for each file: 现在,当我通过浏览器调用
test.php
文件时,它将在每个文件的响应标头中返回以下内容:
text/html; charset=UTF-8
text/css; charset=utf-8
application/javascript; charset=utf-8
I really don't understand why it return the charset in upper case for html
but in lower case for all other content types. 我真的不明白为什么它为
html
返回大写字符集,而对于所有其他内容类型却返回小写字符。 This is not a severe problem of functionality but it really bothers me. 这不是一个严重的功能问题,但确实困扰着我。 To solve this I tried to include the ending
.html
in the AddCharset
like so: 为了解决这个问题,我试图像这样在
AddCharset
包含结尾的.html
:
AddCharset UTF-8 .css .js .html
But this does not change anything, it still returns the the charset for the text/html
file in user case. 但这并没有任何改变,在用户情况下,它仍然返回
text/html
文件的字符集。 Could anyone tell me how to make the server return either consistently upper or lower case charset headers. 谁能告诉我如何使服务器返回一致的大写或小写字符集标头。
After some trying around to see where the charset
header was actually set, I discovered that PHP
outputs a charset automatically so to change the UTF-8
to utf-8
you need to change the Charset
in the php.ini
file. 经过一番尝试以查看
charset
标头的实际设置位置之后,我发现PHP
自动输出了一个字符集,因此要将UTF-8
更改为utf-8
您需要在php.ini
文件中更改Charset
。 This fixed the problem. 这解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.