NitinS
NitinS

Reputation: 99

Zend redirection of 404 page

I am using Zend Framework with WAMP Server on localhost.

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.

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 .

But i want to control this so that if user types any wrong address in the URL it should show 404 error page.

Where is the code written for this "index controller" redirection for wrong address page ?

Thanks in advance...

Upvotes: 1

Views: 1641

Answers (1)

Antonio E.
Antonio E.

Reputation: 4391

You should take a look at 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). It is not intended to catch exceptions raised in other plugins.

Upvotes: 1

Related Questions