简体   繁体   English

404页面的Zend重定向

[英]Zend redirection of 404 page

I am using Zend Framework with WAMP Server on localhost. 我在Zend Framework和本地主机上的WAMP Server中使用。

If I type http://localhost/scmproject/vendors in the URL, it is working fine as it is redirecting to the correct page i have made. 如果我在URL中键入http://localhost/scmproject/vendors ,则它可以正常工作,因为它重定向到我创建的正确页面。

But if i type http://localhost/scmproject/vendors789 or any other address with incorrect Action & controller it is redirecting to the index controller of the project which may be fine . 但是,如果我输入http://localhost/scmproject/vendors789或任何其他不正确的Action&controller地址,它将重定向到项目的索引控制器,这可能很好。

But i want to control this so that if user types any wrong address in the URL it should show 404 error page. 但是我想控制它,以便如果用户在URL中键入任何错误的地址,它应该显示404错误页面。

Where is the code written for this "index controller" redirection for wrong address page ? 错误地址页面的“索引控制器”重定向的代码写在哪里?

Thanks in advance... 提前致谢...

You should take a look at Zend_Controller_Plugin_ErrorHandler . 您应该看看Zend_Controller_Plugin_ErrorHandler A sample usage for this plugin is to register it in the general bootstrap to redirect errors to a standard controller: 此插件的示例用法是在通用引导程序中注册该插件,以将错误重定向到标准控制器:

$plugin = new Zend_Controller_Plugin_ErrorHandler();
$plugin->setErrorHandlerModule('default')
       ->setErrorHandlerController('error')
       ->setErrorHandlerAction('index');

$front = Zend_Controller_Front::getInstance();
$front->registerPlugin($plugin);

(Example taken from the docs). (示例取自文档)。 Mind that, as the docs say: 请注意,正如文档所说:

The ErrorHandler plugin is designed to handle HTTP 404-type errors (page missing) and 500-type errors (internal error). ErrorHandler插件旨在处理HTTP 404类型的错误(页面丢失)和500类型的错误(内部错误)。 It is not intended to catch exceptions raised in other plugins. 它并非旨在捕获其他插件中引发的异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM