[英]ZF2 routing not works properly
我有一个基于提供的骨架的ZF2项目。 我使用ZFTool
制作了一些控制器和动作。 问题是路由器不接受URL。 它说: The requested URL could not be matched by routing
笔记:
该项目位于Apache虚拟主机上
控制器已创建:
$ 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.
并且路由器配置如下:
// ... '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.