mercredi 29 avril 2015

PHP Slim API 404 not found

I'm trying to create an API using php and php slim.

my folder structure:

API:

  • app -> app.js
  • libs -> Slim
  • v1 -> .htaccess and index.php

htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]

index.php

require '.././libs/Slim/Slim.php';
\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();
$app = \Slim\Slim::getInstance();

$app->get('/orderoverview/:customerID', function ($customerID) {
        echo "Hello " . $customerID;

});
$app->run();

This should be easy but every time I go to http://localhost/api/v1/orderoverview/2 I get a 404 Page Not Found.

BUT when I go to http://localhost/api/v1/index.php/orderoverview/2 I do get the result I want to become!

Any remarks or solutions?

Aucun commentaire:

Enregistrer un commentaire