Feb 212021
CentOS Stream 8のApacheで、デフォルトのトップページがzh-cnになります。
(パッケージはhttpd-2.4.37-30.module_el8.3.0+462+ba287492.0.1.x86_64)
/etc/httpd./conf.d/welcome.confで設定されている403 NOT FOUND時のページが表示されるのですが、こちらにはen-USのページも用意されているのに何故だろうと疑問でした。
$ ls -l /usr/share/httpd/noindex/index.html*
-rw-r--r-- 1 root root 4288 Jul 30 2019 /usr/share/httpd/noindex/index.html.en-US
-rw-r--r-- 1 root root 4467 Jun 14 2019 /usr/share/httpd/noindex/index.html.es-ES
-rw-r--r-- 1 root root 4006 Jun 14 2019 /usr/share/httpd/noindex/index.html.zh-CN
-rw-r--r-- 1 root root 4006 Jun 14 2019 /usr/share/httpd/noindex/index.html.zh-HK
-rw-r--r-- 1 root root 4006 Jun 14 2019 /usr/share/httpd/noindex/index.html.zh-TW
curlでトップページを表示してみるとContent-Language: zh-cn
になっています。
$ curl -I http://localhost/
HTTP/1.1 403 Forbidden
Date: Sun, 21 Feb 2021 03:09:51 GMT
Server: Apache/2.4.37 (centos) OpenSSL/1.1.1g
Content-Location: index.html.zh-CN
Vary: negotiate,accept-language
TCN: choice
Last-Modified: Fri, 14 Jun 2019 03:37:43 GMT
ETag: "fa6-58b405e7d6fc0;5bbe58cb80a25"
Accept-Ranges: bytes
Content-Length: 4006
Content-Type: text/html; charset=UTF-8
Content-Language: zh-cn
Apache公式ドキュメントにきちんと回答がありました。
https://httpd.apache.org/docs/2.4/ja/content-negotiation.html#methods
「Apache ネゴシエーションアルゴリズム」の以下の部分です。
- 内容の最も短い variant を選びます。
- 残っている variant の最初のものを選びます。 タイプマップファイルの最初にリストされているか、 variant がディレクトリから最初に読み込まれる時に ASCII順でソートしてファイル名が先頭になったか、のどちらかです。
なるほどです。先のファイルリストをみると確かにzh-*のファイルサイズは4006バイトとen-USやes-ESより小さく、かつzh-CNがファイルリストの先頭にきます。
試しにindex.html.zh-CNのファイルサイズをちょっと増やしてみると、次点のzh-HKに切り替わることが確認できます。
$ sudo sh -c "echo 1 >> /usr/share/httpd/noindex/index.html.zh-CN" $ ls -l /usr/share/httpd/noindex/index.html.zh-* -rw-r--r-- 1 root root 4008 Feb 21 12:28 /usr/share/httpd/noindex/index.html.zh-CN -rw-r--r-- 1 root root 4006 Jun 14 2019 /usr/share/httpd/noindex/index.html.zh-HK -rw-r--r-- 1 root root 4006 Jun 14 2019 /usr/share/httpd/noindex/index.html.zh-TW $ curl -I http://localhost/ HTTP/1.1 403 Forbidden Date: Mon, 21 Feb 2021 03:29:02 GMT Server: Apache/2.4.37 (centos) OpenSSL/1.1.1g Content-Location: index.html.zh-HK Vary: negotiate,accept-language TCN: choice Last-Modified: Fri, 14 Jun 2019 03:37:43 GMT ETag: "fa6-58b405e7d6fc0;5bbe41920b7b6" Accept-Ranges: bytes Content-Length: 4006 Content-Type: text/html; charset=UTF-8 Content-Language: zh-hk
Sorry, the comment form is closed at this time.