我真的不知道这里发生了什么。基本上我有一组路径,其前缀为admin,如下所示:
<?php
/** ------------------------------------------
* Route model binding
* ------------------------------------------
*/
Route::model('user', 'User');
Route::model('role', 'Role');
/** ------------------------------------------
* Admin Routes
* ------------------------------------------
*/
Route::group(array('prefix' => 'admin', 'before' => 'auth'), function() {
# User Management
Route::get('users/{user}/show', 'AdminUsersController@getShow')
->where('user', '[0-9]+');
Route::get('users/{user}/edit', 'AdminUsersController@getEdit')
->where('user', '[0-9]+');
Route::post('users/{user}/edit', 'AdminUsersController@postEdit')
->where('user', '[0-9]+');
Route::get('users/{user}/delete', 'AdminUsersController@getDelete')
->where('user', '[0-9]+');
Route::post('users/{user}/delete', 'AdminUsersController@postDelete')
->where('user', '[0-9]+');
Route::controller('users', 'AdminUsersController');
# User Role Management
Route::get('roles/{role}/show', 'AdminRolesController@getShow')
->where('role', '[0-9]+');
Route::get('roles/{role}/edit', 'AdminRolesController@getEdit')
->where('role', '[0-9]+');
Route::post('roles/{role}/edit', 'AdminRolesController@postEdit')
->where('role', '[0-9]+');
Route::get('roles/{role}/delete', 'AdminRolesController@getDelete')
->where('role', '[0-9]+');
Route::post('roles/{role}/delete', 'AdminRolesController@postDelete')
->where('role', '[0-9]+');
Route::controller('roles', 'AdminRolesController');
# Admin Dashboard
Route::controller('/', 'AdminDashboardController');
});
/** ------------------------------------------
* Frontend Routes
* ------------------------------------------
*/
// User reset routes
Route::get('user/reset/{token}', 'UserController@getReset')
->where('token', '[0-9a-z]+');
// User password reset
Route::post('user/reset/{token}', 'UserController@postReset')
->where('token', '[0-9a-z]+');
//:: User Account Routes ::
Route::post('user/{user}/edit', 'UserController@postEdit')
->where('user', '[0-9]+');
//:: User Account Routes ::
Route::post('user/login', 'UserController@postLogin');
# User RESTful Routes (Login, Logout, Register, etc)
Route::controller('user', 'UserController');
//:: Application Routes ::
# Filter for detect language
Route::when('contact-us', 'detectLang');
# Contact Us Static Page
Route::get('contact-us', function() {
// Return about us page
return View::make('site/contact-us');
});
# Index Page - Last route, no matches
//Route::get('/', array('before' => 'detectLang', 'uses' => 'BlogController@getIndex'));
Route::get('{par1}', function($par1) {
return $par1;
});
Route::get('{par1}/{par2}', function($par1, $par2) {
return $par1 . '-' . $par2;
});
Route::get('/', function() {
return 'route not found';
});
//filters.php
Route::filter('auth', function()
{
if (Auth::guest()) {
Session::put('loginRedirect', Request::url());
return Redirect::to('user/login/');
}
});
这曾经工作正常,但突然决定它不喜欢单词admin作为前缀,所以例如当访问和路由admin / x或admin / x / y / z我得到路线未找到信息。但是出于某种原因,如果我将此前缀更改为其他任何内容,例如sadmin我的路由像以前一样工作。更奇怪的是,如果我尝试像mysite.com/var1/var2这样的东西,我的参数返回路由会返回var1和var2。但如果我执行admin / var1,我会收到路由未找到消息。
任何想法可能会在这里改变....我很确定我没有改变路线文件中的任何内容......我当时正在处理控制器。不幸的是,Ctrl + Z没有保存我,因为我推动了这些改变已经有一段时间了。
答案 0 :(得分:3)
也许尝试删除所有多余的路线并向后工作 - 逐个重建路线?
答案 1 :(得分:1)
非常感谢@The Shift Exchange帮助我解决这个问题。事实证明这是我的过滤器的问题,基本上我是应用基于角色名称的过滤器 - 不幸的是,在测试我的编辑功能时,我无意中编辑了我的管理员角色的名称 - 用户错误!!!
再次感谢您的帮助,也许这会帮助其他人。