Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8481497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:34:19+00:00 2026-06-10T19:34:19+00:00

I have wrote a custom 404 Page Not Found page. But where I have

  • 0

I have wrote a custom 404 Page Not Found page.
But where I have to put it in my Zend Application structure and how to show it?

When a controller couldn’t be found I receive an Invalid controller specified (dsa) error.
And when an action couldn’t be found I receive an Action "wqe" does not exist and was not trapped in __call() error.

Shortly, I don’t want these errors.

How can I detect if the page is not found before rendering? And when I detect it, how can I show my custom error page. At the moment I receive the errors from above but the layout is still displayed.

Do I need some .htaccess rules? Or it can be done with some Zend stuff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:34:21+00:00Added an answer on June 10, 2026 at 7:34 pm

    In your ErrorController

    class ErrorController extends Zend_Controller_Action {
    
      public function errorAction() {
        $errors = $this->_getParam('error_handler');
    
        if (!$errors || !$errors instanceof ArrayObject) {
          $this->view->message = 'You have reached the error page';
          return;
        }
    
        switch ($errors->type) {
          case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
          case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
          case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
            // 404 error -- controller or action not found
            $this->getResponse()->setHttpResponseCode(404);
            $priority = Zend_Log::NOTICE;
            $this->view->error_code = $this->getResponse()->getHttpResponseCode();
            $this->view->message = "Page Not Found";
            $this->renderScript('error/error_404.phtml');
            break;
          default:
            // application error
            print_r($this->getResponse());
            $this->getResponse()->setHttpResponseCode(500);
            $priority = Zend_Log::CRIT;
            $this->view->error_code = $this->getResponse()->getHttpResponseCode();
            $this->view->message = 'Application error';
            if ($log = $this->getLog()) {
            $log->log($this->view->message, $priority, $errors->exception);
            $log->log('Request Parameters', $priority, $errors->request->getParams());
            $this->renderScript('error/error_500.phtml');
            }
    
        // conditionally display exceptions
            if ($this->getInvokeArg('displayExceptions') == true) {
                    $this->view->exception = $errors->exception;
            }
    
            $this->view->request = $errors->request;
            $this->view->error_code = $this->getResponse()->getHttpResponseCode();
            $this->renderScript('error/error_500.phtml');
            break;
        }
    
        // Log exception, if logger available
        if ($log = $this->getLog()) {
          $log->log($this->view->message, $priority, $errors->exception);
          $log->log('Request Parameters', $priority, $errors->request->getParams());
        }
    
        // conditionally display exceptions
        if ($this->getInvokeArg('displayExceptions') == true) {
          $this->view->exception = $errors->exception;
        }
    
        $this->view->request = $errors->request;
      }
    
      public function getLog() {
        $bootstrap = $this->getInvokeArg('bootstrap');
        if (!$bootstrap->hasResource('Log')) {
          return false;
        }
        $log = $bootstrap->getResource('Log');
        return $log;
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wrote a custom MultipleChoiceField. I have everything working ok but when I
I have a client that is running a custom VB 6 application they wrote
I wrote few custom view helpers but I have a little trouble using them.
I have rails application that connects to multiple databases. I wrote custom rake task
I have a custom portlet which use 2 parameters I wrote in my portlet-conf.properties.
I have wrote a method to convert any layout Liner,Relative,Frame etc into Bitmap but
I have a build problem with maven. I wrote a custom checkstyle check for
I am having difficulties applying my custom 404 page in Drupal. So first I
I wrote custom servlet in Liferay and want to know which user page calls
I have an MVC app and I wrote a custom roleprovider for it as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.