douqiao2008
2016-08-31 08:54
浏览 39
已采纳

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

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxi3085 2016-09-02 09:50
    已采纳

    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!

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题