我收到此错误:
Sorry, the page you are looking for could not be found.
1/1
NotFoundHttpException in RouteCollection.php line 143:
in RouteCollection.php line 143
at RouteCollection->match(object(Request)) in Router.php line 746
at Router->findRoute(object(Request)) in Router.php line 655
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 229
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 118
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 86
at Kernel->handle(object(Request)) in index.php line 64
我真的不明白这是什么问题。 我运行以下命令:
composer dump-autoload
php artisan clear-compiled
php artisan route:clear
没有任何效果。
Laravel安装位于子目录(public_html / ecodryer)下,指向公共目录的指针由.htaccess配置:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^landings.yaza.co.il/ecodryer$ [NC,OR]
RewriteCond %{REQUEST_URI} !ecodryer/public/
RewriteRule (.*) /ecodryer/public/$1 [L]
</IfModule>
路线档案:
<?php
Route::get('/', function () {
return view('pages.site.main');
});
有什么建议吗?
提前致谢!
答案 0 :(得分:16)
这是您的routes.php声明的问题,请确保您已为您尝试访问的网址定义了路由。例如:
Route::get('/', 'PageController@index');
您可以在Laravel网站上找到更详细的语法: http://laravel.com/docs/5.1/routing
编辑:
根据您的routes.php - 更改您的路线以反映:
Route::get('ecodryer', function () {
return view('pages.site.main');
});
答案 1 :(得分:3)
有时这种问题伴随着服务器的文件夹结构,例如url,就像localhost/project/
一样。尝试为本地项目创建虚拟主机。它还提供一些额外的好处。
How to create a virtual host on wamp
答案 2 :(得分:0)
对于那些在laravel版本5.4.10(或@Chen Alon提到的5.3以后)中出现类似错误的人,默认情况下已删除routes.php文件,如果您仍想使用它,那么只创建文件是不够。我们需要在RouteServiceProvider.php文件中包含文件&#34; map&#34;功能。在地图功能中添加以下行解决了我的问题:
require app_path('Http/routes.php');
答案 3 :(得分:0)
有时这种问题伴随着 index.php 。通过以下方式测试您的路线:
路线/ index.php的
或
YOURDOMAIN /公共/路线/ index.php的
您可以通过config apache和虚拟主机从URL中删除index.php。 this link可以帮助您。
答案 4 :(得分:0)
Route::get('hello', 'Hello@index');
应该在/projectname/routes/web.php
下