drodsh7940 2016-12-17 17:01
浏览 190
已采纳

Laravel新API不起作用

I'm trying to learn Laravel (5.3.28) and I'm running into an issue with my very first api route not working. I've followed the Laravel docs and can create a new project and can navigate to the Laravel splash screen indicating it's working. I added the following route to routes/api.php to test if I can consume the end-point, but I get an error:

routes/api.php

Route::get('foo', function () {
    return 'Hello World';
});

error

NotFoundHttpException in RouteCollection.php line 161:

I have a dedicated CentOS box running XAMPP for my web server. the address to hit the end-point is http://10.0.0.200/test/api/public/foo.

I'm read that my .htaccess file should be edited, but the few examples I found match what I already have, so I'm a little lost on what to do.

Here is the output for php artisan route:list:

+--------+----------+----------+------+---------+--------------+
| Domain | Method   | URI      | Name | Action  | Middleware   |
+--------+----------+----------+------+---------+--------------+
|        | GET|HEAD | /        |      | Closure | web          |
|        | GET|HEAD | api/foo  |      | Closure | api          |
|        | GET|HEAD | api/user |      | Closure | api,auth:api |
+--------+----------+----------+------+---------+--------------+
  • 写回答

2条回答 默认 最新

  • duanpie2414 2016-12-17 17:43
    关注

    10.0.0.200/test/api/public is the root URL I assume. If yes, then you need to hit 10.0.0.200/test/api/public/api/foo

    I think that your project lies in the folder test/api, what you need is to reconfigure apache ginx to route all requests going to 10.0.0.200/test/ , to start going to {webser root}/test/api/public . This is done in web server configuration files

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 镍氢电池充电器设计实物使用原理
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号