Kohana_Request_Exception [0]:无法找到与 URI 匹配的路由:
我有一个 kohana 网站,我想将其投入生产,但我有一个问题,我不知道如何最好地解决: 如果有人访问相对于我的网站而言不存在的 uri,则会出现一个错误页面,并带有标题消息:
Kohana_Request_Exception [0]:无法 查找与 URI 匹配的路由:(以及此处的 uri)
我想知道当用户访问这样的 URI 时,我是否可以做一些事情将用户重定向到标准 404 页面,可以吗?
非常感谢!
i have a kohana site and i want to put it into production, but i have a problem i don't know how to solve best:
if someone accesses a uri that doesn't exist, relatively to my website, an error page appears, with the header message:
Kohana_Request_Exception [ 0 ]: Unable
to find a route to match the URI: (and the uri here)
i wonder if I can do something to redirect the user to a standard 404 page, when he/she accesses such a URI,can I?
thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 try/catch 块将
$request->execute()
包装在APPPATH/bootstrap.php
中,然后执行您想做的任何操作。我的看起来像这样...
理想情况下 PHP 将支持
finally { ... }
并且我可以在那里进行日志记录和可能的重新抛出,但是你能做什么?You can wrap your
$request->execute()
in yourAPPPATH/bootstrap.php
with a try/catch block and then do whatever you want.Mine looks like this...
Ideally PHP would support
finally { ... }
and I could do the logging and possible re-throwing there, but what can you do?您可以按照 http 异常用户指南中描述的方式处理所有错误:
http://kohanaframework.org/3.1/guide/kohana/errors#http-exception-handling
You can handle all errors the same way it is described in the userguide for http exceptions:
http://kohanaframework.org/3.1/guide/kohana/errors#http-exception-handling
试试这个
Try out this one