이제 출력 할 수 http://localhost/posts/PHP에서 ID로 나머지 API를 호출하는 방법?
[
{
"id": "1",
"title": "first post",
"description": "here my first post",
"status": "Y"
},
{
"id": "2",
"title": "second post",
"description": "here my second post",
"status": "Y"
}
]
여기 내 소스 코드
if ($_SERVER['REQUEST_METHOD'] == "GET"){
@List($objnm, $objid) = explode('/', $_GET['url']);
if ($objnm == 'posts')
{
$post = $db->query('SELECT * FROM post WHERE status="Y"');
echo json_encode($post, JSON_PRETTY_PRINT);
}
else
{
http_response_code(401);
}
}
내 htaccess로
RewriteEngine On
RewriteRule ^([^/]+)/? index.php?url=$1 [L,QSA]
내가 나를 도울 수 http://localhost/posts/1 하나의 출력이 필요하십니까?
가능한 중복 /book/1234"](https://stackoverflow.com/questions/11696718/htaccess-rewrite-book- phpid-1234-to-book-1234) – sumit