15

I'm searching for a solution ... it's getting so frustrating. After a fresh installation of Lumen by Laravel, I simply can't access the "/" route. When I try to, it throws an error:

NotFoundHttpException in RoutesRequests.php line 443:

in RoutesRequests.php line 443
at Application->handleDispatcherResponse(array('0')) in RoutesRequests.php line 380
at Application->Laravel\Lumen\Concerns\{closure}() in RoutesRequests.php line 629
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 382
at Application->dispatch(null) in RoutesRequests.php line 327
at Application->run() in index.php line 28
4

4 回答 4

66

知道了!……

解决方案是在第 28 行更改 public/index.php:

$app->run();

$app->run($app->make('request'));

不知道为什么,也许你知道。

于 2016-04-05T21:02:33.247 回答
3

我今天遇到了同样的问题。

我使用 URL http://localhost/lumen.api/public/访问它,我认为这是错误的原因。

为了解决这个问题,这就是我所做的:

首先,我在 Xampp 上配置了一个新的 VirtualHost 条目,就我而言,它位于“C:\xampp\apache\conf\extra\httpd-vhosts.conf”中:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/lumen.api/public"
    ServerName lumen.api
    ServerAlias www.lumen.api
    ErrorLog "logs/lumen.api-error.log"
    CustomLog "logs/lumen.api-access.log" common
    <Directory "C:/xampp/htdocs/lumen.api/public">
        AllowOverride All
        Require all Granted
    </Directory>
</VirtualHost>

并在 Xampp 上重新启动 Apache。

然后我编辑了我的主机文件 (c:\windows\system32\drivers\etc\hosts) 以将新地址映射到我的本地主机。

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost   
    127.0.0.1       lumen.api

我再次尝试使用新的 URL http://lumen.api并且错误消失了。

于 2017-01-04T19:27:59.847 回答
3

问题可以通过改变来解决

    $app->run();

/public/index.php

    $request = Illuminate\Http\Request::capture();
    $app->run($request); 
于 2017-04-04T12:32:49.893 回答
0

可能 .htaccess 文件已被删除或从public文件夹中以某种方式丢失。没有它,重写 URL 将不起作用。

检查这个:https ://github.com/laravel/lumen/blob/master/public/.htaccess

于 2018-04-29T15:05:50.273 回答