新手apache2.4.16默认编码问题

zw2864076 2015-07-28 03:32:29
安装了apache2.4.16以后,默认编码是UTF-8,成改成GB2312或是关闭这个编码让系统自动识别用什么编码。
问题是在百度上查了很多关于httpd.conf 的配制信息都要说在找到AddDefaultCharset On|Off|charset我在配制文件里都找了还是没有这个,自己添加了以不行。AddDefaultCharset GB2312,请高手解答一下,小弟感激不尽
不知道问题出在那里,


以下是在官方文档上找到的,
AddDefaultCharset Directive

Description: Default charset parameter to be added when a response content-type is text/plain or text/html
Syntax: AddDefaultCharset On|Off|charset
Default: AddDefaultCharset Off
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Core
Module: core
This directive specifies a default value for the media type charset parameter (the name of a character encoding) to be added to a response if and only if the response's content-type is either text/plain or text/html. This should override any charset specified in the body of the response via a META element, though the exact behavior is often dependent on the user's client configuration. A setting of AddDefaultCharset Off disables this functionality. AddDefaultCharset On enables a default charset of iso-8859-1. Any other value is assumed to be the charset to be used, which should be one of the IANA registered charset values for use in Internet media types (MIME types). For example:

AddDefaultCharset utf-8
AddDefaultCharset should only be used when all of the text resources to which it applies are known to be in that character encoding and it is too inconvenient to label their charset individually. One such example is to add the charset parameter to resources containing generated content, such as legacy CGI scripts, that might be vulnerable to cross-site scripting attacks due to user-provided data being included in the output. Note, however, that a better solution is to just fix (or delete) those scripts, since setting a default charset does not protect users that have enabled the "auto-detect character encoding" feature on their browser.
...全文
332 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
englishplusplus 2015-10-13
  • 打赏
  • 举报
回复
#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default. To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8
这是我从我自己的httpd.conf 文件copy的,apache 2.4
如果您想使用浏览器默认选择或者允许在html中的META重载此选项,请注释这个指令
by English++小组,englishpp.com
yukuren 2015-09-12
  • 打赏
  • 举报
回复
我也没找到,没有高手来解答一下吗

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧