Friday, July 5, 2013

Hide controller name from URL


To override your default route and prevent you from visiting controllers and modules that are opened via

URLs

like: example.com/controller/action to example.com/action

Place below mention code in your /application/Bootstrap.php file:

public function _initCustomRoute()
{
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $route = new Zend_Controller_Router_Route(':action', array(
        'module'     => 'default',
        'controller' => 'index'
    ));
    $router->addRoute('default-override', $route);

}

1 comment:

  1. Hello There

    i have placed this code in /application/Bootstrap.php file

    but nothing happens

    please can you help me to solve my problem

    ReplyDelete