所以!
我安装了zfcUser模块。我试着打开site/user链接。啊,真灵。当我尝试打开site/user/ (添加了/符号)时,它并不是开放的。为什么?
我想,我必须编辑路由器。我在module.config.php目录的\vendor\zf-commons\zfc-user\config\文件中找到了这个:
'route' => '/user',如何改变这一点,以便允许/user和/user/ urls?
为什么可以同时编写/application和/application/,但没有在配置文件中指定?:
'route' => '/application',发布于 2014-04-29 12:33:36
有几种方法使尾随斜杠工作,一是创建一个分段类型的路线标记尾随斜杠为非强制性的,例如。
'users' => array(
'type' => 'Segment',
'options' => array(
// Change this to something specific to your module
'route' => '/users[/]',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'User',
'action' => 'index',
),
),还可以将子文本路由添加到另一个文本路由,如下所示
'users' => array(
'type' => 'Literal',
'options' => array(
// Change this to something specific to your module
'route' => '/users',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'User',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
),
),
),
),如果希望在用户使用ZfcUser时使用尾随斜杠,则可以扩展其路由规则,在任何其他注册模块中添加此配置。
'zfcuser' => array(
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
),
),
),
),https://stackoverflow.com/questions/23362586
复制相似问题