I am using a mod_rewrite
to forward all api calls to apiHandler.php
with the follow .htaccess
:
RewriteEngine On
RewriteRule ^api/(.*)$ /apiHandler.php
The problem is, inside apiHandler.php
, I'm losing the data from php://input
.
header("Access-Control-Allow-Headers: Content-Type");
header("Content-Type: application/json");
$requestBody = json_decode(file_get_contents("php://input"));
echo json_encode($requestBody);
exit();
Whenever I hit my api with: "http://localhost:80/api/testing"
I get back a null from $requestBody
, but when I use "http://localhost:80/apiHandler.php"
, I get back the correct value from $requestBody
.
Any ideas?