我在用着Laravel4框架,我遇到了这个问题。
我想根据请求的 url 显示自定义 404 错误。
例如:
Route::get('site/{something}', function($something){
return View::make('site/error/404');
});
and
Route::get('admin/{something}', function($something){
return View::make('admin/error/404');
});
的价值'$something'
并不重要。
所示示例仅适用于一个段,即'site/foo'
or 'admin/foo'
。
如果有人要求'site/foo/bar'
or 'admin/foo/bar'
laravel 会抛出默认的 404 错误。
App::missing(function($exception){
return '404: Page Not Found';
});
我试图在 Laravel4 文档中找到一些东西,但没有一个适合我。
请帮忙 :)
谢谢你!
In app/start/global.php
App::missing(function($exception)
{
if (Request::is('admin/*'))
{
return Response::view('admin.missing',array(),404);
}
else if (Request::is('site/*'))
{
return Response::view('site.missing',array(),404);
}
else
{
return Response::view('default.missing',array(),404);
}
});
在你看来,你可以找到$something
with {{ Request::path(); }}
or {{ Request::segment(); }}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)