How do I define a default fallback route in Laravel?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 13:14:09

问题


I'm currently upgrading a custom CMS from Laravel 3 to Laravel 4 (this upgrade is important for various reasons).

In the existing version, it has routing set up so that routes can be individually defined--but if someone tries to load a route that is not specifically defined, the system catches it and sends it to a "page processor"--which essentially checks to see if the CMS page/post exists in the database.

The "fallback" or "default" route processing line in Laravel 3 looked like this:

Route::get('(.*)', array('uses' => 'myPageLoading@method'));

My problem is that this syntax is not supported in Laravel 4. How do I do this in Laravel 4?


回答1:


Got it.

Laravel 4 Syntax:

Route::any('{all}', array('uses' => 'myPageLoading@method'))->where('all', '.*');


来源:https://stackoverflow.com/questions/18646606/how-do-i-define-a-default-fallback-route-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!