1
Route::get('user/profile', function () {
return 'test' })->name('profile');

But I always get error when I call the address/profile if i use address/user/profile it works just fine.

The error list shown in my browser :

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

Where do I miss ? thanks in advance.

user3859812
  • 11
  • 1
  • 6
  • To get address/profile your route needs to be Route::get('profile').... Going to address/user/profile is the exact route you have defined thats why that one will work – Adam Sep 28 '16 at 13:34
  • Also, what are you trying to achieve exactly? – Adam Sep 28 '16 at 13:35
  • Yeah, I just figured it out. I just bought a new laravel book and I thought we can call the alias we make using name() as the URL. – user3859812 Sep 28 '16 at 13:48

2 Answers2

0

You need to change route from user/profile to profile

Route::get('profile', function () {
   return 'test' })->name('profile');

name() only create alias name for route not changing the URL

Patryk Uszyński
  • 1,069
  • 1
  • 12
  • 20
0
Route::get('user/profile', function () {
return 'test'; })->name('profile');

Try This.Hope It will work!!

Asm Arman
  • 359
  • 6
  • 24