title: Zend Framework route for Sub Folders with Rest
body: <p>For my current Application Setup i am trying to create a routing for Standard Controllers and Rest Controllers.</p>
  
  <p>This is my Structure.</p>
  
  <pre><code>/application
    /modules
      /module
        /controllers
          /Admin
          /Api
  </code></pre>
  
  <p>To call a Controller within the admin Sub Folder:</p>
  
  <pre><code>/module/admin_controller/action
  </code></pre>
  
  <p>I want to change this to:</p>
  
  <pre><code>/admin/module/controller/action
  </code></pre>
  
  <p>In my current setup:</p>
  
  <pre><code>/* application.ini */
  ;Default route
  resources.router.routes.defaultmodule.type = Zend_Controller_Router_Route_Module
  resources.router.routes.defaultmodule.defaults.module = "default
  
  
  ; APi route
  resources.router.routes.api.type = Zend_Controller_Router_Route
  resources.router.routes.api.route = ":api" 
  resources.router.routes.api.reqs.api = "api"
  resources.router.routes.apichain.type = Zend_Controller_Router_Route_Chain
  resources.router.routes.apichain.chain = "api, defaultmodule"
  
  ; Admin route
  resources.router.routes.admin.type = Zend_Controller_Router_Route
  resources.router.routes.admin.route = ":admin" 
  resources.router.routes.admin.reqs.admin = "admin"
  resources.router.routes.adminchain.type = Zend_Controller_Router_Route_Chain
  resources.router.routes.adminchain.chain = "admin, defaultmodule"
  
  
  /* Plugin */
  class Pwb_Plugin_ControllerRoute
      extends Zend_Controller_Plugin_Abstract
  {    
      public function routeShutdown(Zend_Controller_Request_Abstract $request)
      {
          if ($request-&gt;getParam('admin')) {
              $admin_controller = $request-&gt;getParam('admin') . '_' . $request-&gt;getControllerName();
              $request-&gt;setControllerName($admin_controller);
          }
  
          if ($request-&gt;getParam('api')) {
              $admin_controller = $request-&gt;getParam('api') . '_' . $request-&gt;getControllerName();
              $request-&gt;setControllerName($admin_controller);
          }
      }
  }
  
  /* Module Bootstrap */
  class Acl_Bootstrap
      extends Zend_Application_Module_Bootstrap
  {
      protected function _initRestRoute()
      {
          $this-&gt;bootstrap('frontController');
          $frontController = Zend_Controller_Front::getInstance();
          $restRoute = new Zend_Rest_Route(
                  $frontController,
                  array(),
                  array(
                      'acl' =&gt; array(
                          'api_role'
                      ))
          );
          $frontController-&gt;getRouter()-&gt;addRoute('restAcl', $restRoute);
      }
  
  }
  </code></pre>
  
  <p>The issue here really is that some Controllers in the API folder are Rest but not all of them.</p>
  
  <p>/api/acl/role is routing correctly to the indexAction as expected.</p>
  
  <p>/api/acl/role/1 is looking for the action "1" where i would expect it to route to getAction.</p>
  
  <p>How could i integrate the Zend_Route_Rest from the module Bootstrap into these rulesets.</p>
  
  <p>Every help would be much appreciated.</p>