我的router.php
中有以下代码Route::group(array('before' => 'auth'), function()
{
Route::get('account/(:all?)', function() {});
Route::get('facebook/(:all?)', function() {});
});
Route::controller(Controller::detect());
当用户未登录时,它运行良好。但是一旦他成功登录并被重定向到所请求的页面,该页面就不会显示任何内容;只是一个空白页面。我试图使用:any而不是:all并且它做同样的事情。
有人可以发现问题吗?
答案 0 :(得分:0)
您的路由映射到空闭包。您需要返回一些内容或将它们映射到控制器。
Route::get('account/(:any?)', function() {
return "Hello World";
});
Route::get('account/(:any?)', function() {
return View::make('accounts.index');
});
//assuming you have an AccountController.php
Route::get('account/(:any?)', 'account@index');
//automatically route all methods of a controller
Route::controller('account');
答案 1 :(得分:0)
显然,我没有找到使用组过滤器的更好解决方案。我现在用来将客户重定向到auth的方式是:
Route::filter('before', function()
{
$open_routes = array(
'',
'home',
'auth',
'help'
);
if(!in_array(URI::segment(1), $open_routes) && Auth::guest()) {
return Redirect::to('/auth/login');
}
});