我正在使用Slim Framework编写API,但我收到了404错误
require ('Slim/Slim/Slim.php');
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->response()->header('Content-Type', 'application/json;charset=utf-8');
$app->get('/', 'test'); // It is OK and I can see the return of my function "test" when I access domain/api
$app->get('/groups', 'getGroups'); // 404 error while I try to go to domain/api/groups
有人知道如何修复此路线问题吗?
答案 0 :(得分:1)
它看起来像是一个htaccess问题。必须将htaccess放在您的api文件夹中。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]