2012-11-01 21 views
0

在Bootstrap.php中我有一些使用Zend_Controller_Router_Route_Regex的自定义路由。 除非用户在地址栏中输入错误的链接,否则一切正常。Zend Framework:如何处理“没有路由匹配请求”的错误?

例:

http://mysite/en/1-some-article.html =>这是在引导路线相匹配的有效链路。

但是,当用户输入了错字的错误,如:

http://mysite/en/1-some-article.**html'** or http://mysite/en/1-some-article.**hhtml**,他们不匹配引导任何路线,然后Zend框架抛出一个异常,如:没有路由匹配请求

反正有处理它就像重定向到“无匹配路线”的自定义页面一样?

任何帮助将不胜感激。感谢您的提前!

配置(从下面评论)

[production] 
phpSettings.display_startup_errors = 1 
phpSettings.display_errors = 1 
phpSettings.date.timezone = "Europe/London" 
;includePaths.library = APPLICATION_PATH "/../library" 
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" 
bootstrap.class = "Bootstrap" 
appnamespace = "" 
;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 
resources.frontController.params.displayExceptions = 0 
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" 
resources.modules = "" 
autoloaderNamespaces.Fxml = "Mycms_" 
autoloaderNamespaces.Fxml = "Fxml_" 
+0

在您的生产环境中,您可以将'resources.frontController.params.throwExceptions'设置为false。这会导致错误落入'ErrorController'。请参阅http://framework.zend.com/manual/1.12/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler.fourohfour和http://framework.zend.com/manual/1.12 /en/zend.controller.exceptions.html – Phil

+0

@Phil:我的application.ini中有这行,但没有任何改变。 –

+0

而您正在使用prod设置运行您的应用程序? – Phil

回答

0

为了使用ErrorController的,你需要在前端控制器throwExceptions属性设置为false。把这个在您的[production]配置部分

resources.frontController.params.throwExceptions = 0 

http://framework.zend.com/manual/1.12/en/zend.controller.exceptions.htmlhttp://framework.zend.com/manual/1.12/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler.fourohfour

我在上面的评论中提到过这个,但你似乎错过了它(你有displayExceptions设置为false而不是throwExceptions)。

+0

是的,我把这行写入我的application.ini中,但是也没有改变。系统不断抛出异常。 –

相关问题