Fat-Free Framework 中最简单的路由(通过 Composer 安装)

The easiest routing in Fat-Free Framework (installed via Composer)

我想通过 F3 为我的项目配置路由。首先,我通过 Composer 安装了他,然后我使用了 This and This.

中关于路由引擎的说明

然后在浏览器中,如果我要 URL localhost/myproject/ 它工作正常。但是如果我要 URL localhost/myproject/route1 它对我不起作用并给出 404 服务器状态错误。为什么?

我的代码在"index.php":

require_once('vendor/autoload.php');

$f3 = \Base::instance();

$f3->route('GET /', function() {
    echo '123';
});

$f3->route('GET /route1', function() {
    echo '345';
});

$f3->run();

最简单的项目,什么都没有,只F3。我哪里错了?

确保你的文件夹中有这个 .htaccess 如果这没有帮助,请在 RewriteBase / 中评论并调整路径以匹配你 sub-folder ("myproject").