[英]Get all routes, Laravel 4
我想要的只是使用一个控制器,它应该处理我的laravel 4应用程序的每个请求。 问题是stackoverflow或其他地方的解决方案都没有对我有用。
这就是我现在拥有的:
Route::any('(.*)', function(){
return View::make('hello');
});
现在浏览页面时我每次都会收到错误说:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
希望有人能帮助我!
正则表达式设置为要求,而不是直接在路径中。
Route::any('{all}', function($uri)
{
return View::make('hello');
})->where('all', '.*');
Route::group(array('prefix' => '/', 'before' => 'MAKEYOUROWNFILTER'), function()
{
// your routers after the / ....
});
//并在filters.php中
Route::filter('MAKEYOUROWNFILTER', function()
{
// do stuff or just
return View::make('hello');
});
扩展#Jason Lewis的重定向到根页面的答案:
Route::any('{all}', function($uri)
{
return Redirect::to('/');
})->where('all', '.*');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.