0
votes

I have a problem with URL rewrite in Zend Framework, I hope someone helps me solve that.

I need to rename module admin as admindev in URL apply for all controller and action.

Here my code write in Bootstrap.php:

public function _initModuleRoutes()
{
    $this->bootstrap('FrontController');
    $frontController = $this->getResource('FrontController');
    $router = $frontController->getRouter();
    $route = new Zend_Controller_Router_Route(
        'admindev/:action/*',
        array(
            'module'=>'admin',
            'controller'=>':controller',
            'action'=>':action'
        )
    );      
    $router->addRoute('admin',$route);
    return $router;
}

Thanks all,

1

1 Answers

1
votes

You didn't specify the :controller parameter in the route.

Try it like that:

public function _initModuleRoutes()
{
    $this->bootstrap('FrontController');
    $frontController = $this->getResource('FrontController');
    $router = $frontController->getRouter();
    $route = new Zend_Controller_Router_Route(
        'admindev/:controller/:action/*',
        array(
            'module'=>'admin',
            'controller'=>':controller',
            'action'=>':action'
        )
    );      
    $router->addRoute('admin',$route);
    return $router;
}

Also you can achieve the same effect with application.ini configuration:

resources.router.routes.admindev.type = "Zend_Controller_Router_Route"
resources.router.routes.admindev.route = "/admindev/:controller/:action/*"
resources.router.routes.admindev.defaults.module = "admin"

Other application.ini tips and tricks here