I have a custom module, with an IndexController and an indexAction. This has a route with a fronName set in the config.xml(for example angular-app). On this page I have an angular app, with it's own routing. Everything works fine until I don't refresh the browser. After refresh I get 404.
How can I setup magento's router to handle every request under the angular-app with the IndexController:indexAction.

So what I would like:

  • request: http://domain.com/angular-app -> IndexController:indexAction
  • request: http://domain.com/angular-app/x/y/z -> IndexController:indexAction where x, y, z are dynamic parameters.

1 Answer 1


I am not expert in angular app but as per as my understand,You want to send all angular requests with prefix angular-app in your url.

So,you need to create new custom router. To understand the custom route,Follow the below link.

For your case, using controller_front_init_routers add custom router at system by $front->addRouter('addangularapp',$this); on function initControllerRouters of class ModuleNameSpace_ModuleName_Controller_Router

<!--  define route -->
      <angularapp> <!--  router identifier -->
  <!-- event for add a router -->
          <add_angularapp_route>  <!-- observer identifier -->

Then at match() validate and modify http request (Zend_Controller_Request_Http). and if request have contain angular-app then it internally set IndexController as controller as ,indexAction as request action and set your module as request module.


Controller code may like:

class ModuleNameSpace_ModuleName_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract{
     * Initialize Controller Router
     * @param Varien_Event_Observer $observer

    public function initControllerRouters($observer){


    /* validate and modify the  request
     *  Params Zend_Controller_Request_Htt
    public function match(Zend_Controller_Request_Http $request){

        /* If Magento Magento is not install then 
         * redirect to installer url

        Mage::log('aaa'.$requestPathInfo.'StoreId'.Mage::app()->getStore()->getId(), null, 'logfile.log');
        /* check -review-form not exit
         * then immediate return false
            return  false;

        /* get productut from url 
            by  substr   

        $condition=new Varien_Object(array('product_url'=>$producturl,

        Mage::dispatchEvent('angular_app_controller_router_match_before', array(
                'router'    => $this,
                'condition' => $condition

            return true;

            return  false;

        ->setParam('customparam', $requestPathInfo);

        return  true;



Note: code is not tested.

same concet havec in https://magento.stackexchange.com/a/70619/4564 answer


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.