问题
I get this error:
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
I really don't understand what is the issue. I run the following commands:
composer dump-autoload
php artisan clear-compiled
php artisan route:clear
Nothing worked.
Laravel installation is under a subdirectory (public_html/ecodryer) and pointer to the public directory is configured by .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>
Route file:
<?php
Route::get('/', function () {
return view('pages.site.main');
});
Any suggestions?
Thanks ahead!
回答1:
This is an issue with your routes.php declaration, make sure you have defined a route for the url you are trying to access. For example:
Route::get('/', 'PageController@index');
You can find more detailed syntax on the Laravel website: http://laravel.com/docs/5.1/routing
Edit:
Based on your routes.php - Change your Route to reflect as such:
Route::get('ecodryer', function () {
return view('pages.site.main');
});
回答2:
Sometimes this kind of problem comes with folder structure of the server such as url comes like localhost/project/
. Try to create a virtual host for your local project. It's giving some extra benefits also.
How to create a virtual host on wamp
回答3:
For those who are getting similar error in laravel version 5.4.10(or 5.3 onwards as mentioned by @Chen Alon), routes.php file has been removed by default and if you still want to use it then just creating file is not enough. We need to include file in RouteServiceProvider.php file inside "map" function. Adding below line inside map function resolved the issue for me :
require app_path('Http/routes.php');
回答4:
Sometimes this kind of problem comes with index.php. test your route by:
route/index.php
or
yourdomain/public/Route/index.php
you can remove index.php from URL by config apache and virtual host. this link can help you.
回答5:
Route::get('hello', 'Hello@index');
It should be under /projectname/routes/web.php
来源:https://stackoverflow.com/questions/31648243/laravel-5-notfoundhttpexception-in-routecollection-php-line-143