Skip to content


Apache ネゴシエーション

このエントリーをはてなブックマークに追加
はてなブックマーク - Apache ネゴシエーション
Share on Facebook
Post to Google Buzz
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed
Share on GREE

 先日のエントリー「クールなURI どんなURIが素敵か?」に続いて、Apacheにおけるネゴシエーションを設定してみました。
 やりたいことは「拡張子なし」のURIが指定された場合でも、ブラウザーから送られてくるAcceptヘッダーにより適切と判断されたファイルを表示することです。


環境

  • Apache/2.2.14

手順

  1. httpd.confや.htaccessなどの設定ファイルに以下の記述を追加
  2. Options MultiViews
  3. httpd再起動

動作確認

  1. 以下の2ファイルを作成
  2. test1.txt
    test1.html
  3. ブラウザからhttp://localhost/test1をリクエスト
  4.  →txtよりhtmlの方が優先度が高いので、test1.htmlが表示される

  5. test1.htmlをtest2.htmlに名前変更し、http://localhost/test1をリクエスト
  6.  →test1という名称のファイルが一つしか存在しないので、test1.txtが表示される

関連するかもしれない記事



他のブログも読む

Posted in Apache.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

*