获取所有路由,Laravel 4

2022-01-02 00:00:00 routing php laravel laravel-4

我现在想要的只是使用一个控制器来处理我的 Laravel 4 应用程序的每个请求.问题是 stackoverflow 或其他地方的解决方案都没有对我有用.

What I want is just to use one controller at the moment which should handle every request that comes to my laravel 4 application. The problem is that none of the solutions on stackoverflow or elsewhere are working for me.

这就是我目前拥有的:

Route::any('(.*)', function(){
  return View::make('hello');
});

现在浏览页面时,我每次都收到一条错误消息:

Now when browsing to the page I get an error everytime saying:

Symfony  Component  HttpKernel  Exception  NotFoundHttpException

希望有人能帮助我!

推荐答案

正则表达式被设置为需求,而不是直接在路由中.

Regular expressions are set as requirements and not directly in the route.

Route::any('{all}', function($uri)
{
    return View::make('hello');
})->where('all', '.*');

相关文章