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

但我總是得到錯誤,當我調用地址/ profile文件 如果我使用的地址/用戶/ profile中它工作得很好。NotFoundHttpException PHP Laravel 5.2

錯誤列表顯示在我的瀏覽器:

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 

我在哪裏錯過? 在此先感謝。

+0

要獲得地址/配置您的路線必須路線::得到(「曲線」).... 會地址/用戶/配置文件是你已經定義這就是爲什麼一會工夫 – Adam

+0

同樣的確切路線,你想要達到什麼目的? – Adam

+0

是的,我只是想通了。我剛剛購買了一本新書,我認爲我們可以使用name()作爲URL來調用我們製作的別名。 – user3859812

回答

0

您需要更改從user/profile路線profile

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

name()只爲路線創建別名不改變URL

+0

那麼,我應該怎麼做,我可以將URL作爲別名的名稱? – user3859812

+0

哦,我看到了.. 我剛剛發現了它。謝謝你的回答 – user3859812

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

嘗試This.Hope它將工作!

+0

仍然是一樣的錯誤先生。 – user3859812

+0

然後我不知道該怎麼做。 –

相關問題