トップ 差分 一覧 ping ソース 検索 ヘルプ PDF RSS ログイン

Apache HTMLファイルが、UTF-8で送信されてしまう



目次



記事一覧

キーワード

Apache HTMLファイルが、UTF-8で送信されてしまう


HTMLファイル自体のcharsetをShift_JIS等としても、ブラウザ側で、エンコーディングが、UTF-8と判定されてしまう。

html

<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">

AddDefaultCharset

レスポンスのコンテントタイプが text/plain あるいは text/html の場合に限り、レスポンスに追加するメディアタイプの文字セットパラメータ (文字エンコーディングの名前) のデフォルト値を、このディレクティブで指定。

telnetで確認

# telnet 192.168.0.5 80
Trying 192.168.0.5...
Connected to 192.168.0.5 (192.168.0.5).
Escape character is '^]'.
GET /tipslib/index.html HTTP/1.1
host:typea.dip.jp

HTTP/1.1 200 OK
Date: Fri, 16 Mar 2007 21:51:33 GMT
Server: Apache/2.2.3 (Fedora)
Last-Modified: Fri, 16 Mar 2007 00:54:44 GMT
ETag: "7283cf-32f-af715d00"
Accept-Ranges: bytes
Content-Length: 815
Connection: close
Content-Type: text/html; charset=UTF-8

/etc/httpd/conf/httpd.conf の AddDefaultCharsetをコメントアウトする

#
# 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



YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto

Copyright© 矢木 浩人 All Rights Reserved.