TAGS :Viewed: 4 - Published at: a few seconds ago

[ url routing in zend framework ]

Hi I created several module for my own CMS like category, article, core , ...
now how can I access these modules with url like:

http://localhost/mycms/admin/category
http://localhost/mycms/admin/article , ...

note: the admin is not module, it's only prefix

Answer 1


In "application/Bootstrap.php":

public function _initRoute(){    

$frontController = Zend_Controller_Front::getInstance();

            $router = $frontController->getRouter(); // returns a rewrite router by default
            $router->addRoute(
                'category',
                new Zend_Controller_Router_Route('admin/category/:controller/:action',
                                                 array('module' => 'category',
                                                        'controller' => 'index',
                                                       'action' => 'index'))
            );
}

Then type in URL : ex : http://localhost/mycms/admin/category and you get there.

Same with others.