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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:17:05+00:00 2026-06-17T16:17:05+00:00

I am doing web application using Zend framework. Library I am using is 1.12

  • 0

I am doing web application using Zend framework. Library I am using is 1.12

In the project I have two modules i.e. Default and Admin

Default module have some static pages for that I have set router. In the router I have set controller and action, please refer below code.

In Bootstrap file,

    protected function _initModules() {

        $defaultstaticRoute = new Zend_Controller_Router_Route(
                                '/:staticpage',
                                array('module' => 'default',
                                    'controller' => 'index',
                                    'action' => 'displaystatic',
                                    'staticpage' => '([a-z0-9]+-)*[a-z0-9]+'  
                                    ),                 
                                array(
                                   'staticpage' => '([a-z0-9]+-)*[a-z0-9]+'                 
                                )
                            );

            $router->addRoute('defaultstatic', $defaultstaticRoute);
    }

In the controller,

class IndexController extends Zend_Controller_Action
{
    public function init()
    {

    }

    public function indexAction()
    {

    }

    public function displaystaticAction()
    {       
        //get the file name from the url
       $page = $this->getRequest()->getParam('staticpage');

        //render the view
       $this->render($page);

     }
}

The above code is working fine if the url is like
http://myproject/index or http://myproject/aboutus

But, if the url without page name, like

http://myproject/

then it redirects me to 404 not found page while it have to show the index page.

I have tracked the issue, I found that it comes in the Index Controller’s init() method and after it goes to 404.

What is the wrong in my code?

Edit:
The above issue is solved by the solution is given by Tim Fountain,
But I found another issue and not solved by above trick.
Below is the code,

In bootstrap file:

 $servicesstaticRoute = new Zend_Controller_Router_Route(
    'services/:pagename',
    array('module' => 'default',
            'controller' => 'services',
            'action' => 'displayservices',
            'pagename' => 'index'    
        ),                 
        array(
           'pagename' => '([a-z0-9]+-)*[a-z0-9]+'                 
        )
    );
$router->addRoute('servicesstatic', $servicesstaticRoute);

For the above code http://myproject/services/index is worked but http://myproject/services/ not worked.

  • 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-17T16:17:06+00:00Added an answer on June 17, 2026 at 4:17 pm

    The first array in your route provides default values. If you want http://myproject/ to render the static page ‘index’, you need to change the staticpage value in this array to ‘index’:

    $defaultstaticRoute = new Zend_Controller_Router_Route(
                                '/:staticpage',
                                array('module' => 'default',
                                    'controller' => 'index',
                                    'action' => 'displaystatic',
                                    'staticpage' => 'index'  
                                    ),                 
                                array(
                                   'staticpage' => '([a-z0-9]+-)*[a-z0-9]+'                 
                                )
                            );
    

    That way, if staticpage is not present in the URL it will be given the value ‘index’.

    If you want the index action of your controller to be rendered instead, just remove the default value for staticpage and your route will no longer match this request.

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

Sidebar

Related Questions

I have a web application that will be doing some processing with submitted data.
I'm a Perl programmer doing some web application testing using Selenium . I was
I am doing web application Project in GWT. I am using RPC, which is
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate
i am doing a web application in flex. i have a list of items
I have a problem here. Right now I'm doing my Web Based Application, my
I have a web application where I am doing a Response.Redirect(Register.aspx) page in a
I'm doing a performance study for a web application framework running on Apache Tomcat
I've got a .NET 3.5 web application written in C# doing some URL rewriting

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.