2016-02-15 109 views
1

我已經定義了路由,當我正確地訪問localhost/project/public/admins那麼該項目的負載,但是當我剛剛加入/admins那麼localhost/admins負荷是不能訪問localhost/project/public/admins/laravel 5.1:路線問題

Route::get('admins', function() { 
    return view('admins/index'); 
}); 

那裏並且拋出404

回答

2

試試這個Route::get('/admins'.....)

它會好得多,如果你使用前綴/分組,以避免這種問題。這裏是示例

Route::group(['prefix'=>'admin', 'middleware'=>'auth'], function(){ 
    Route::get('dashboard',        ['as'=>'user-dashboard','uses'=>'Admin\[email protected]']); 

    # User Role Management 
    Route::group(['prefix'=>'roles', 'middleware'=>'auth'],function(){ 
     Route::get('show',       ['as'=>'roles-show', 'uses'=>'Admin\[email protected]']); 
     Route::get('data',       ['as'=>'roles-data', 'uses'=>'Admin\[email protected]']); 
     Route::get('create',       ['as'=>'roles-create', 'uses'=>'Admin\[email protected]']); 
     Route::post('create',       ['as'=>'roles-store', 'uses'=>'Admin\[email protected]']); 
     Route::get('edit/{id}',      ['as'=>'roles-edit', 'uses'=>'Admin\[email protected]']); 
     Route::post('edit/{id}',      ['as'=>'roles-update', 'uses'=>'Admin\[email protected]']); 
     Route::post('delete',       ['as'=>'roles-delete', 'uses'=>'Admin\[email protected]']); 
    }); 

}); 
1

爲了避免這種類型的錯誤,您需要配置.htaccess文件。 .htaccess配置文件用於在沒有index.php或public的情況下運行文件。