【发布时间】:2014-03-25 00:27:50
【问题描述】:
请原谅我对 ZF2 的新手。 我想从顶层路由到控制器...
在 ZF2 Skeleton 中,它的设置是这样的,这样路由在应用之后被分段:
http://www.example.com/application[/:controller[/:action]]
但我不想像这样进入应用程序路径并进入控制器:
http://www.example.com/[:controller[/:action]]
我进行了广泛的搜索,但无法让它发挥作用。 我的 module.config.php 设置如下:
/* in module.config.php */
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Login' => 'Application\Controller\LoginController',
),
),
如果我浏览到 http://www.example.com/login ,它会显示“请求的 URL 无法通过路由匹配。”我想我缺少基本概念... =(
【问题讨论】:
标签: routes zend-framework2 segment