【问题标题】:Laravel 5 api route returning 404 apache2Laravel 5 api路由返回404 apache2
【发布时间】:2018-02-11 16:28:55
【问题描述】:

我无法让我的 api 调用返回 ubuntu 16.04 上的任何数据。 这是我在 routes/api.php 中的方法:

Route::get('comments', function() {
   // If the Content-Type and Accept headers are set to 'application/json', 
   // this will return a JSON structure. This will be cleaned up later.
   return Comment::all();
});

这是在 RouteServiceProvider 中:

protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }

当我点击 localhost/api/cmets 时,我得到 404。

我确保在我的 site.conf 中设置了 AllowOverride All。

我的数据库有一个 cmets 表,其中包含使用工匠种子填充的数据

【问题讨论】:

    标签: laravel-5 routes apache2 ubuntu-16.04 restful-architecture


    【解决方案1】:

    事实证明,我的所有 api 调用都设置正确。我可以说是因为 php artisan route:list 是正确的。我也正确设置了我的 apache2 站点。问题最终是我没有为我的基本文件夹设置正确的权限。

    使用这个命令:sudo chmod 755 -R yourprojectbasefolderlocation

    【讨论】:

      猜你喜欢
      • 2021-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-13
      • 1970-01-01
      • 2021-04-12
      • 2015-12-26
      • 2019-04-02
      相关资源
      最近更新 更多