繁体   English   中英

ZF2路由无法正常工作

[英]ZF2 routing not works properly

我有一个基于提供的骨架的ZF2项目。 我使用ZFTool制作了一些控制器和动作。 问题是路由器不接受URL。 它说: The requested URL could not be matched by routing

笔记:

  1. 该项目位于Apache虚拟主机上

  2. 控制器已创建:

     $ zf.php create controller user Application The controller user has been created in module Application. $zf.php create action register user Application Creating action 'register' in controller 'Application\\Controller\\user\u0026#39;. Created view script at ./module/Application/view/application/user/register.phtml The action register has been created in controller Application\\Controller\\user. 
  3. 并且路由器配置如下:

     // ... 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Application\\Controller\\Index', 'action' => 'index', ), ), ), // The following is a route to simplify getting started creating // new controllers and actions without needing to create a new // module. Simply drop new controllers in, and you can access them // using the path /application/:controller/:action 'application' => array( 'type' => 'Literal', 'options' => array( 'route' => '/application', '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( ), ), ), ), ), ), ), 

分段controller/action路径在application注册为子路径,这意味着您必须在前面键入应用程序: www.mysite.local.com/application/user/register 如果您不想这样,您必须更改路线定义。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM