title: Zend 2 Framework Routing
body: <p>I'm struggling with this problem and can't get over it.</p>
  
  <p>What I want to achieve is a route like this: /rolepermission[/:roleid]/permissions[/:permissionid][/action/:action]</p>
  
  <p>Currently I came up with something like this:</p>
  
  <pre><code>        'rolepermission' =&gt; array(
              'type' =&gt; 'literal',
              'options' =&gt; array(
                  'route' =&gt; '/rolepermission',
                  'constraints' =&gt; array(),
                  'defaults' =&gt; array(
                      'controller' =&gt; 'My\Controller\RolePermission',
                      'action' =&gt; 'index',
                  ),
              ),
              'may_terminate' =&gt; true,
              'child_routes' =&gt; array(
                  'rolepermissionroleid' =&gt; array(
                      'type' =&gt; 'segment',
                      'options' =&gt; array(
                          'route' =&gt; '/[:roleid]',
                          'constraints' =&gt; array(
                              'roleid' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                          ),
                          'defaults' =&gt; array(
                              'action' =&gt; 'detail',
                          ),
                      ),
                      'may_terminate' =&gt; true,
                      'child_routes' =&gt; array(
                          'rolepermissionpermissions' =&gt; array(
                              'type' =&gt; 'literal',
                              'options' =&gt; array(
                                  'route' =&gt; '/permissions',
                                  'constraints' =&gt; array(),
                                  'defaults' =&gt; array(
                                      'action' =&gt; 'index'
                                  ),
                              ),
                              'may_terminate' =&gt; true,
                              'child_routes' =&gt; array(
                                  'rolepermissionpermissionid' =&gt; array(
                                      'type' =&gt; 'segment',
                                      'options' =&gt; array(
                                          'route' =&gt; '/[:permissionid]',
                                          'constraints' =&gt; array(
                                              'permissionid' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                                          ),
                                          'defaults' =&gt; array(
                                          ),
                                      ),
                                      'may_terminate' =&gt; true,
                                      'child_routes' =&gt; array(
                                          'rolepermissionaction' =&gt; array(
                                              'type' =&gt; 'segment',
                                              'options' =&gt; array(
                                                  'route' =&gt; '/action/[:action]',
                                                  'constraints' =&gt; array(
                                                      'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                                                  ),
                                                  'defaults' =&gt; array(
                                                      'action' =&gt; 'index'
                                                  ),
                                              ),
                                              'may_terminate' =&gt; false,
                                              'child_routes' =&gt; array(),
                                          ),
                                      ),
                                  ),
                              ),
                          ),
                      ),
                  ),
              ),
          ),
  </code></pre>
  
  <p>When routing to /rolepermission/permissions I constantly get 'permissions' substituted for :roleid. I'm expecting here nothing to be substituted due to not passing a roleid. What am I doing wrong?</p>
  
  <p>Thanks in advance,
  cheers</p>