使用Event :: override不显示Custom Error 500页面-Laravel [英] Custom Error 500 page not displaying using Event::override - Laravel
本文介绍了使用Event :: override不显示Custom Error 500页面-Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在404事件而不是500事件中成功使用Event :: Override函数.我只是希望该事件通过Flash消息重定向到首页,因为我可以处理404个事件.
I am able to use the Event::Override function successfully with the 404 event but not the 500 event. I simply wish the event to redirect to the front page with a flash message, as I am able to do fine with 404 events.
我还有别的事情要做才能使500个事件也重定向到我的首页吗?请参阅下面的routes.php文件中的代码:
Is there something else I need to do to get the 500 events also redirecting to my front page? see code below in routes.php file:
Event::listen('404', function() {
return Response::error('404');
});
Event::listen('500', function() {
return Response::error('500');
});
Event::override('404', function() {
Session::flash('error', '<strong>Error 404 - Not Found.</strong> The page you are looking for is either <u>invalid</u> or <u>may no longer exist</u>. You are now back at our home page.');
return Redirect::to_route('home');
});
Event::override('500', function() {
Session::flash('error', '<strong>Error 500 - Internal Server Error.</strong> Something went wrong on our servers, apologies for that. Please contact us if this persists.');
return Redirect::to_route('home');
});
有什么想法吗?
推荐答案
我能够通过直接在\ application \ views \ error文件夹中更新500错误文件来解决此问题.
I've been able to work around this by updating the 500 error file directly in the \application\views\error folder.
这篇关于使用Event :: override不显示Custom Error 500页面-Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文