我正在尝试使用PHP构建一个简单的RESTful API。该请求适用于URL路径中的普通查询,但是,在实现REST方法时,我收到“404 URL not found”错误
的.htaccess
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^([a-zA-Z|_-]*)$ index.php?name=$1 [nc,qsa]
index.php(摘录)
// process client request (via URL)
header("Content-Type:application/json");
include('functions.php');
if(!empty($_GET['name'])){
$name=$_GET['name'];
$result=get_items_by_category("$name");
if(empty($result)){
print($name);
deliver_response(200,"Duh, gee, Mort, there's nothing here!",NULL);
}else{
deliver_response(200,"Hit the road,Jack!",$result);
}
}else{
deliver_response(400,"This is not the request you're looking for",NULL);
}
答案 0 :(得分:1)
引用:
<div style="width: 300px; overflow-x: auto; overflow-y: hidden;">
// your content goes here
</div>
正则表达式中没有括号,所以是的,它不匹配。
您对网址语法的计划是什么?可以帮助你使用正则表达式来使它工作。