laravel路由和404错误 [英] laravel routing and 404 error
本文介绍了laravel路由和404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想指定是否在URL地址中输入除现有路由以外的任何内容(在route.php中,然后显示404页.
I want to specify that if anything entered in the url address other than existing routes (in routes.php, then show 404 page.
我知道这一点:
App::abort(404);
但是如何指定除了定义的路径以外的所有其他部分?
but how can I specify the part where everything else except the routes defined?
推荐答案
您可以将其添加到filter.php文件中:
You can add this to your filters.php file:
App::missing(function($exception)
{
return Response::view('errors.missing', array(), 404);
});
并创建errors.missing
视图文件以向他们显示错误.
And create the errors.missing
view file to show them the error.
还请查看错误和错误;记录文档
编辑
如果您需要将数据传递到该视图,则第二个参数是可以使用的数组:
If you need to pass data to that view, the second parameter is an array you can use:
App::missing(function($exception)
{
return Response::view('errors.missing', array('url' => Request::url()), 404);
});
这篇关于laravel路由和404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文