title: ZF2 use child route if child and parent matches
body: <p>Is it possible in ZF2 routing to have a generic parent route, matching all public actions, but override specific areas with a custom child-route and controller?</p>
  
  <p>What I want:</p>
  
  <pre><code>/parent =&gt; matches parent controller
  /parent/edit =&gt; matches parent controller editAction
  /parent/childsection =&gt; matches child controller
  /parent/childsection/edit =&gt; matches child controller editAction
  </code></pre>
  
  <p>I couldn't come up with any configuration that fits my needs. Following the config I thought would work - but ZF2 routes terminates at the parent route cause <code>childsection</code> could be an action too.</p>
  
  <pre><code>'parent' =&gt; array(
      'type' =&gt; 'Segment',
      'may_terminate' =&gt; true,
      'options' =&gt; array(
          'route' =&gt; '/parent[[/:action][/:id]]',
          'constraints' =&gt; array(
              'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
              'id' =&gt; '[0-9]+',
          ),
          'defaults' =&gt; array(
              'controller' =&gt; 'Application\Controller\Parent',
              'action' =&gt; 'index',
          ),
      ),
      'child_routes' =&gt; array(
          'child' =&gt; array(
              'type' =&gt; 'Segment',
              'options' =&gt; array(
                  'route' =&gt; '/childsection/:action[/:id]',
                  'constraints' =&gt; array(
                      'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                      'id' =&gt; '[0-9]+',
                  ),
                  'defaults' =&gt; array(
                      'controller' =&gt; 'Application\Controller\Child',
                  ),
              ),
          ),
      ),
  ),
  </code></pre>
  
  <p>The only thing that worked was a minimal parent literal route and 2 child routes - 1 generic and 1 specific for the child section. But in this case I have to redirect or generate urls using <code>-&gt;toRoute('parent/default'...)</code></p>
  
  <p>Is there any other elegant solution or is this simply not possible?</p>