Slim 3框架组路由

Slim 3 framework group routing

我想在 Slim 3 Framework 中使用组路由,但我总是得到 "Object not found! The requested URL was not found on this server"。我不确定我做错了什么。这是我写的代码:

<?php

require "vendor/autoload.php";

$app = new \Slim\App();

// API Version Group
$app->group("/v1", function() use($app) {
   $app->get("/test1", function() use($app){
       return "from v1 tes1";
   });
});

//Run the app
$app->run();

?>

我运行这个地方喜欢:http://localhost/MyAPI/v1/test1。谁能帮帮我?

谢谢

我通过在根文件夹中添加 .htaccess 解决了这个问题。

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

感谢所有帮助过我的人!