Issues

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

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.


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(
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    ...

return array(
    'router' => array(
        'routes' => array(
            'frontend' => array(
                'options' => array(
                    'route'    => '/',
                ),
            ),
        ),
    ),
    ...

Comments

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.

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