2016-11-14 235 views
0

我在我的本地mac pc中託管的項目中使用此路由,但它在工作,但是當我將其上載到Ubunto服務器時發生了路由衝突。Laravel路由與資源路由衝突

Route::group(['prefix'=>'report', 'middleware' => ['auth','session', 'complete_profile']], function() { 
    Route::get('/get_query', '[email protected]_queries'); 
}); 

Route::group(['middleware' => ['auth','session', 'complete_profile']], function(){ 
    Route::resource('report','ReportController'); 
}); 

例如,當我用它去該控制器的show($id)方法在線ubunto服務器形式的第一條路線report/get_query,但在當地其工作。 我該怎麼做?

+0

您是否嘗試在資源路由後放置第一個路由組? – prateekkathal

+0

@prateekkathal我測試過了,但是在那個時候我的本地mac發生了衝突 – jones

+0

請注意,在Ubuntu中,一切都區分大小寫。即使index.Php和index.php會產生巨大的差異。檢查你是否有任何大小寫錯誤。發生在我身上很多 – Markinson

回答

1
Route::group(['prefix'=>'report', 'middleware' => ['auth','session', 'complete_profile']], function() { 
    Route::resource('/','ReportController',['except' => ['show']]); 
    Route::get('/get_query', '[email protected]_queries'); 
}); 

資源路由具有http方法的預定義路由。例如reporte資源具有路線:

Route::get('report/{report}','[email protected]'); 

解決辦法是排除一些methodes(從問題的REST資源的路線),或做出一些路線這不會與航線資源衝突。

您可以看到您已註冊的運行什麼路線:

php artisan route:list 

也爲報告一個路由組足夠的只是資源的路線把「/」。