Issues

ZF2-442: "/" route can't have child_routes

Issue Type: Bug Created: 2012-08-02T15:09:21.000+0000 Last Updated: 2012-08-02T22:52:27.000+0000 Status: Resolved Fix version(s): Reporter: Alex Pogodin (alex_pogodin) Assignee: Ben Scholzen (dasprid) Tags: - Zend\Mvc\Router

  • child
  • routing

Related issues: Attachments:

Description

The following config (see module.config.php below) works as expected, until I decide to make the site public. To do so, I just override route from "/beta" to "/" (see config/autoload/production.local.php). Doing so breakes all child routes, generating smth like "//about" which is not correct and interpreted by browsers as protocol-less link.

I didn't find any note in documentation prohibiting usage of "/" route with child_routes option.

<pre class="highlight">
return array(
    'router' => array(
        'routes' => array(
            'frontend' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'    => '/beta',
                    'defaults' => array(
                        'controller'    => 'Index',
                        'action'        => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'about' => array(
                        'type'    => 'Literal',
                        'options' => array(
                            'route'    => '/about',
                            'defaults' => array(
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    ...



<pre class="highlight">
return array(
    'router' => array(
        'routes' => array(
            'frontend' => array(
                'options' => array(
                    'route'    => '/',
                ),
            ),
        ),
    ),
    ...

Comments

Posted by Ben Scholzen (dasprid) on 2012-08-02T21:11:57.000+0000

You actually have to use '' as empty base route in that case (although pretty useless, better to remove that parent route at all). Using an empty literal is broken right now though, but there's already an open bug report about it. To be fixed before final.

Posted by Alex Pogodin (alex_pogodin) on 2012-08-02T22:52:27.000+0000

Maybe it is better to right trim slashes from parent route? Solves this issue and occasional mistakes...

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts