[英]Laravel 5.2 route Not working with error NotFoundHttpException in RouteCollection.php line 161
[英]NotFoundHttpException named route PHP Laravel 5.2
Route::get('user/profile', function () {
return 'test' })->name('profile');
但是当我调用地址/配置文件时,如果我使用地址/用户/配置文件,它总是会出错。
我的浏览器中显示的错误列表:
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 821
at Router->findRoute(object(Request)) in Router.php line 691
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
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 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{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 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
我在哪里错过? 提前致谢。
您需要将路径从user/profile
profile
更改为profile
Route::get('profile', function () {
return 'test' })->name('profile');
name()
仅为不更改URL的路由创建别名
Route::get('user/profile', function () {
return 'test'; })->name('profile');
试试This.Hope它会工作!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.