我有几条路线不起作用,我不明白为什么,因为所有其他路线都起作用,这里是我的 module.config.php :
return array(
'controllers' => array(
'invokables' => array(
'FrontApp\Controller\Index' => 'FrontApp\Controller\IndexController',
'FrontApp\Controller\User' => 'FrontApp\Controller\UserController',
),
),
'router' => array(
'routes' => array(
'confirm' => array(
'type' => 'Literal',
'options' => array(
'route' => '/confirm',
'defaults' => array(
'controller' => 'FrontApp\Controller\Index',
'action' => 'confirm',
),
),
),
'user' => array(
'type' => 'Literal',
'options' => array(
'route' => '/connexion',
'defaults' => array(
'controller' => 'FrontApp\Controller\User',
'action' => 'index',
),
),
),
'detail' => array(
'type' => 'Segment',
'options' => array(
'route' => '/:type/:location/:id',
'constraints' => array(
'type' => '[a-zA-Z][a-zA-Z0-9_-]*',
'location' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'FrontApp\Controller\Index',
'action' => 'detail',
),
),
),
'search' => array(
'type' => 'Segment',
'options' => array(
'route' => '/:type[/:location]',
'constraints' => array(
'type' => '[a-zA-Z][a-zA-Z0-9_-]*',
'location' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'FrontApp\Controller\Index',
'action' => 'search',
),
),
),
'front' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'FrontApp\Controller\Index',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/front-layout.phtml',
'layout/frontlayout' => __DIR__ . '/../view/layout/front-layout.phtml',
'frontapp/index/index' => __DIR__ . '/../view/front-app/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
'front' => __DIR__ . '/../view',
'searcher' => __DIR__ . '/../view',
'detail' => __DIR__ . '/../view',
'user' => __DIR__ . '/../view',
'confirm' => __DIR__ . '/../view',
),
),
'module_layouts' => array(
'FrontApp' => 'layout/frontlayout',
'BackApp' => 'layout/backlayout',
),);
所以当我尝试时:
我的网站/-> 工作
mywebsite/one-type -> 工作
mywebsite/one-type/one-location -> 不工作
mywebsite/one-type/one-location/on-id -> 不工作
我的网站/连接->工作
我的网站/确认 -> 工作
我有点困惑,因为它就像你不能使用不同的路线类型。因此,对于不起作用的路线,我要么有“....无法渲染模板“布局/布局...”错误,当我添加与“布局/前端布局”相同的路径时,该错误会得到解决' 在 template_map 键中(我也不太明白为什么但它有效,所以如果你能启发我,我将非常感激),或者,“请求的 URL 无法通过路由匹配。”和这个错误,我被卡住了,因为我看不出问题出在哪里:/
希望你能帮忙:)