流明5.5总是得到404错误

时间:2018-01-19 11:33:31

标签: php laravel apache lumen

当我尝试输入[mydomain.com]时,我会看到默认版本页面:

Lumen (5.5.2) (Laravel Components 5.5.*)

当我尝试输入[mydomain.com] / api / user时,我收到404错误。

我的web.php如下所示:

$router->get('/', function () use ($router) {
    return $router->app->version();
});

$router->group(['prefix' => 'api'], function () use ($router) {
    // show
    $router->get('user', 'UserController@show');
});

我错过了什么?有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

我仍然不能100%确定为什么会出现这种情况,导致在同一台服务器上额外的流明项目甚至在我的修复完成之前就已经工作了,但我找到了原因:

问题取决于重写引擎的问题。如果您遇到同样的问题,很容易找到。如果您在每条路线上获得404,那么"/"会尝试在您的网址中添加"index.php"(例如:domain.com/index.php/user而不是domain.com/user)。如果现在可以使用该路由,您可以检查您的apache配置并更改

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

此外,您可以通过将以下行添加到流明项目的.htaccess文件夹中的\public来检查您的reirte引擎是否正常工作:

<IfModule mod_rewrite.c>
  Redirect 301 / https://google.com
  [...]

如果您在申请任何路线时未被重定向到Google,则需要检查您的配置。