如何在Laravel中定义默认的后备路由? [英] How do I define a default fallback route in Laravel?

查看:487
本文介绍了如何在Laravel中定义默认的后备路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将自定义CMS从Laravel 3升级到Laravel 4(出于各种原因,这一升级很重要).

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

在现有版本中,它已经设置了路由,以便可以分别定义路由-但是,如果有人尝试加载未明确定义的路由,则系统会捕获该路由并将其发送到页面处理器"- -实质上检查数据库中是否存在CMS页面/帖子.

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.

Laravel 3中的后备"或默认"路由处理行如下所示:

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

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

我的问题是Laravel 4不支持此语法.如何在Laravel 4中做到这一点?

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

推荐答案

知道了.

Laravel 4语法:

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

这篇关于如何在Laravel中定义默认的后备路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆