トップ 一覧 ping 検索 ヘルプ 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|http://httpd.apache.org/docs/2.2/ja/mod/core.html]
レスポンスのコンテントタイプが 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