Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework: How to intentionally throw a 404 error?

I would like to intentionally cause a 404 error within one of the controllers in my Zend Framework application. How can I do this?

like image 619
Andrew Avatar asked Nov 15 '10 21:11

Andrew


People also ask

How do I trigger a 404 error?

One typical trigger for an error 404 message is when the page has been deleted from the website. The page was moved to another URL and the redirection was done incorrectly. You entered an incorrect URL address. Although it happens very rarely, sometimes the server malfunctions.

What does post 404 mean?

404 Error means that the page that has to process the post request can't be loaded or not exists.

What is Javascript error 404?

The HTTP 404 Not Found response status code indicates that the server cannot find the requested resource. Links that lead to a 404 page are often called broken or dead links and can be subject to link rot.


1 Answers

A redirect to a 404 would be:

throw new Zend_Controller_Action_Exception('Your message here', 404); 

Or without Exception:

$this->_response->clearBody(); $this->_response->clearHeaders(); $this->_response->setHttpResponseCode(404); 
like image 67
Wouter Dorgelo Avatar answered Oct 30 '22 03:10

Wouter Dorgelo