如何在HTTP Content-Type响应头中指定字符集? [英] How to specify the character set in the HTTP Content-Type response header?
问题描述
我使用Google提供的 Page Speed 应用程式测试了我的网站,其中一个建议是在HTTP Content-Type响应头声明它比仅在元标记中更好。
这里是我理解我需要写:
Content-Type:text / html; charset = UTF-8
..但是我应该放在哪里呢?我在共享服务器上。
谢谢!
:添加到根目录中的 .htaccess 文件:
AddDefaultCharset UTF-8
它将修改标题:
Content-Type text / html
...到此:
Content-Type text / html; charset = UTF-8
://nginx.org/en/docs/http/ngx_http_charset_module.html#charset> doc ] [ serverfault Q ] 服务器{
#other server config ...
charset utf-8;
}
add charset utf-8;
到服务器阻止(并重新加载nginx配置)
I had my site tested with the Page Speed app from Google and one of the suggestions was to specify the character set in the HTTP Content-Type response header claiming it was better than just in a meta tag.
Here's what I understand I need to write: Content-Type: text/html; charset=UTF-8
..but where exactly should I put this? I'm on a shared server.
Thank you!
Apache: add to your .htaccess file in root directory:
AddDefaultCharset UTF-8
It will modify the header from this:
Content-Type text/html
...to this:
Content-Type text/html; charset=UTF-8
nginx [doc] [serverfault Q]
server {
# other server config...
charset utf-8;
}
add charset utf-8;
to server block (and reload nginx config)
这篇关于如何在HTTP Content-Type响应头中指定字符集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!