【问题标题】:Slim framework 404 and rout errosSlim 框架 404 和路由错误
【发布时间】:2015-09-25 20:12:20
【问题描述】:

我正在使用 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

有人知道如何解决这个路线问题吗?

【问题讨论】:

  • 您的问题解决了吗?我更新了我的答案以真正回答您的问题..
  • 是的,谢谢,我想为您的答案投票,但我没有这样做的声誉。对不起=/
  • 你可以接受我的回答 - 在这里描述:meta.stackexchange.com/a/5235

标签: frameworks routes http-status-code-404 slim


【解决方案1】:

它看起来像一个 htaccess 问题。 htaccess 必须放在你的 api 文件夹中。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-26
    • 2015-04-30
    • 1970-01-01
    • 2012-04-02
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多