ZF2 - 路由无法匹配请求的 URL


ZF2 - The requested URL could not be matched by routing

当我转到

本地主机/应用程序/公共/spanel/test/index

此应用程序有一个sPanel模块。它有一个带有 indexAction() 的测试控制器

这是sPanel''config''module.config.php

<?php
return array(
    'controllers' => array(
        'invokables' => array(
            'sPanel'Controller'Test' => 'sPanel'Controller'TestController',
        ),
    ),
    'router' => array(
        'routes' => array(
            'spanel' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'    => '/test[/:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id'     => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'sPanel'Controller'Test',
                        'action'     => 'index',
                    ),
                ),
            ),
        ),
    ),
    'view_manager' => array(
        'template_path_stack' => array(
            'spanel' => __DIR__ . '/../view',
        ),
    ),
);
首先,

我强烈建议您开始使用虚拟主机来摆脱烦人的localhost/bla/public

其次,您尝试访问此路线:yourdomain/spanel/test/index,但没有迹象表明您将零件/spanel分配到路线中的任何位置,您分配的只是/test[...]

简而言之,您想访问yourdomain/test/index或者想要修改路线以包含/spanel部分