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 8899675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:54:56+00:00 2026-06-15T00:54:56+00:00

How to perform routes in Zend Framework 1.x and also redirect custom error messages?

  • 0

How to perform routes in Zend Framework 1.x and also redirect custom error messages?

  • 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-15T00:54:57+00:00Added an answer on June 15, 2026 at 12:54 am

    To perform customized routes:

    Put the following in your bootstrap.php file

    function _initRoutes() {
        $front_controller = Zend_Controller_Front::getInstance();
        $router = $front_controller->getRouter();
    
        $router->addRoute('customName', new Zend_Controller_Router_Route(
            '/customName/:dataVariable', array('controller' => 'YourController', 'action' => 'YourAction')
        ));
    }
    

    then, in your controller action, you will access it with a data variable which you have just set.

    For example:
    For Category – Post display

    function _initRoutes() {
        $front_controller = Zend_Controller_Front::getInstance();
        $router = $front_controller->getRouter();
    
        $router->addRoute('category', new Zend_Controller_Router_Route(
            '/post/:postId', array('controller' => 'category', 'action' => 'post')
        ));
    }
    

    then in category controller and post action, I will use $this->getRequest()->getParam('postId');

    which will frame url as : example.com/post/123

    ZF1 comes you a predefined ErrorController, you can use it.

    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;
      }
    
    }
    

    You can set HTTP_STATUS_CODES from the list but, make sure you give user’s browser and search bots the right statuses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to globally redirect my users if a custom error is thrown in
I have an MVC site which has routes which I need to redirect with
I have several links I'm trying to create to either perform custom controller methods
Started working with RoR again! I'm having trouble getting my config/routes.rb file to perform.
I want to perform some AJAX style data retrieval using the Java Play Framework
i am implementing the Zend Regex Routing, and i have to perform multiple checks
I perform this kind of query in my Python code to conn = rdbms.connect(instance=_INSTANCE_NAME,
I perform some large downloads. I start a download being connected to 3G, all
ISQL Perform Screen: I have a date column (format=mmm-dd-yyyy) used for storing Date Manufactured.
I perform an AJAX request to a PHP script in JavaScript and by using

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.