11月 022010
 

该功能使得服务器可以根据agent指定的http头来选择合适的资源。
涉及的http头包括: Accept-*
涉及的Apache中的知识: 类型表

1。 需要模块 : modules/mod_negotiation.so
2。 需要在目录的Options中添加: MultiViews;  如: Options FollowSymLinks MultiViews Indexes
3。 参考文档: http://apache.jz123.cn/content-negotiation.html
4。 该功能可能会影响到rewrite,参考: http://www.linuxpk.com/4941.html

apache根据你给的资源名称a,查找所有的a.*资源,加入有两种资源: a.txt 和a.php, 在类型表中查出:
.txt 对应文档类型为: text/plain 
.php 对应文档类型为: application/x-httpd-php

如果请求时使用的 accept为: text/plain ,则返回a.txt
如果请求时使用的 accept为: application/x-httpd-php ,则返回a.php
如果请求时使用的accept为: text/none ,找不到这种类型,则协商失败,apache返回406,并返回所有可用的类型列表,如:

Not Acceptable

An appropriate representation of the requested resource /a could not be found  on this server.

Available variants:

        

  • a.php , type application/x-httpd-php
  •     

  • a.txt , type text/plain
 Posted by at 上午 1:27

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据