Slim 3框架组路由
问题描述:
I want to use group routing in Slim 3 Framework, but I always get "Object not found! The requested URL was not found on this server". I am not sure what I did wrong. Here's the code I wrote:
<?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();
?>
I ran this locally like : http://localhost/MyAPI/v1/test1
. Can anyone help me?
Thanks
答
I fixed this issue just by adding .htaccess in the root folder.
#.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Thanks for everyone who helped me!