【发布时间】:2010-12-31 07:40:32
【问题描述】:
我想安排一些事情,例如 GET 请求
http://example.com/user/foo@bar.com
内部调用脚本
/var/www/example.com/rest/user/GET.php
对同一 URL 的 PUT 请求在内部调用脚本
/var/www/example.com/rest/user/PUT.php
其他 HTTP 动词 POST 和 DELETE 以此类推。
通过<Script> 指令几乎可以实现这一点,但它并不完全有效,因为“Script with a method of GET will only be called if there are query arguments present”。这意味着如果 Apache 是通过配置的
<Location /user>
Script GET /rest/user/GET.php
Script PUT /rest/user/PUT.php
</Location>
然后,同时 GET 请求
http://example.com/user/foo@bar.com?foo=bar
将调用GET.php,如果请求不包含查询字符串“foo=bar”,则不包含。
(还有,为什么<Script>一开始是这样设计的?)
【问题讨论】:
标签: apache http rest routing scripting