| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

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

提供: MyMemoWiki
ナビゲーションに移動 検索に移動

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

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

html

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

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

telnetで確認

  1. # telnet 192.168.0.5 80
  2. Trying 192.168.0.5...
  3. Connected to 192.168.0.5 (192.168.0.5).
  4. Escape character is '^]'.
  5. GET /tipslib/index.html HTTP/1.1
  6. host:typea.dip.jp
  1. HTTP/1.1 200 OK
  2. Date: Fri, 16 Mar 2007 21:51:33 GMT
  3. Server: Apache/2.2.3 (Fedora)
  4. Last-Modified: Fri, 16 Mar 2007 00:54:44 GMT
  5. ETag: "7283cf-32f-af715d00"
  6. Accept-Ranges: bytes
  7. Content-Length: 815
  8. Connection: close
  9. Content-Type: text/html; charset=UTF-8

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

  1. #
  2. # Specify a default charset for all content served; this enables
  3. # interpretation of all content as UTF-8 by default. To use the
  4. # default browser choice (ISO-8859-1), or to allow the META tags
  5. # in HTML content to override this choice, comment out this
  6. # directive:
  7. #
  8. #AddDefaultCharset UTF-8