Zend Framework 2: Redirect to 404 page in Controller

I've been getting into trouble several hours with redirect to 404 page in Zend Framework 2.

Question in StackOverflow: http://stackoverflow.com/questions/21622849/use-the-same-error-handler-in-different-modules-in-zend-framework-2

Before that, I'm using the following code:

$this->getResponse()->setStatusCode(404);
return;

It works fine.

However, after I create the 404 error page. I found it won't redirect you to the error page with the code above.

If you want to redirect to the 404 error page, you should use following code:

return $this->notFoundAction();
Contact Us
  • SenseTime Research, Shenzhenwan Sci. and Tech. Ecological Garden
  • cshzxie [at] gmail [dot] com