Zend Framework 2 xampp到生产服务器路由器问题

时间:2013-08-12 03:20:25

标签: zend-framework migration xampp zend-framework2 routes

我的应用程序在xampp环境中正常工作,但在上传到单元测试服务器后,它遇到了错误。

未找到

在此服务器上找不到请求的URL / application / public / login。

module.config.php

'router' => array(
    'routes' => array(
        'login' => array(
            'type'    => 'segment',
            'options' => array(
                'route'         => '/login',
                'constraints'   => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'     => '[0-9]+',
                ),
                'defaults'   => array(
                    'controller' => 'loginController',
                    'action'     => 'index',
                ),
            ),
                'may_terminate' => true,
                'child_routes' => array(
                        'process' => array(
                                'type'    => 'Segment',
                                'options' => array(
                                        'route'    => '/[:action]',
                                        'constraints' => array(
                                                'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                                        ),
                                        'defaults' => array(
                                        ),
                                ),
                        ),
                ),                  
        ),
        'logout' => array(
            'type'  => 'segment',
            'options' => array(
                'route'     => "/logout",
                'defaults'  => array(
                    'controller'    => 'loginController',
                    'action'        => 'logout'
                )
            )
        ),
    ),
),      

1 个答案:

答案 0 :(得分:0)

1)必须将'public'目录指定为文件C:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf中的根目录:

# Once for all hosts 
NameVirtualHost *:80 

# For each host
<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/SkeletonApplication/public"
   ServerName localhost.myapp
   <Directory "C:/xampp/htdocs/SkeletonApplication/public>
      AllowOverride All
      Order deny,allow
      Deny from all
      Allow from localhost
   </Directory>
   DirectoryIndex index.html index.php
</VirtualHost>

2)在您的文件C:\ Windows \ system32 \ drivers \ etc \ hosts:

127.0.0.1 localhost.myapp

3)在您的浏览器中:

http://localhost.myapp/login

4)您的“登录”路线的类型为“文字”,而不是“细分”。没有“约束”。