我真的不知道这里发生了什么。本质上,我有一组以 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 并没有救我,而且我已经有一段时间没有推送更改了。