
ブログのマークダウン版を提供したいです。http://myblog.com/some/post/
次の 2 つのリクエストを想像してください。
Accept: text/html
->http://myblog.com/some/post/index.html
Accept: text/markdown
->http://myblog.com/some/post/index.md
これを実行するには nginx をどのように設定すればよいですか?
私は読むドキュメントindex
しかし、コンテンツネゴシエーションについては全く触れられていませんでした。
答え1
インデックスファイルでコンテンツネゴシエーションを使用する必要があるだけの場合は、index
を使用して定義された変数でディレクティブを使用できますmap
。このドキュメント詳細については。
例えば:
map $http_accept $myindex {
default index.html;
~*text/markdown index.md;
}
index $myindex index.html;