Zend Framework 2 路由无法正常工作 Windows 7

Zend Framework 2 routing not working properly Windows 7

我阅读了此处发布的所有问题,但找不到解决问题的方法。

我有 windows 7、xampp、apache 2.4、php 5.6、zend 框架 2

我创建了一个名为 Application

的示例应用程序

这是我的 .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我的配置文件是这样的

   'translator' => array(
        'locale' => 'en_US',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
            'pattern'  => '%s.mo',
        ),
    ),
),
'controllers' => array(
    'invokables' => array(
        'Application\Controller\Login' => 'Application\Controller\LoginController',
        'Application\Controller\Index' => 'Application\Controller\IndexController'
    ),
),

http://localhost:8080/lizziap/ 这个有效

localhost:8080/lizziap/Index 这行不通

localhost:8080/lizziap/Login 这行不通

localhost:8080/Index 这不起作用

找不到页面。 路由无法匹配请求的URL。

无异常可用

非常感谢任何帮助...谢谢!

这就是配置现在的样子并且可以正常工作

'router' => array(
    'routes' => array(
        'login' => array(
            'type' => 'segment',
            'options' => array(
                'route'    => '/login[/:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'=>'[0-9a-zA-Z]*',
                ),
                'defaults' => array(
                    'controller' => 'Application\Controller\Login',
                    'action'     => 'login',

                ),
            ),
        ),
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Index',
                    'action'     => 'index',
                ),
            ),
        ),

也许我的配置文件可以帮到你:

return array(
'controllers' => array(
    'invokables' => array(
        'Auth\Controller\Auth' => 'Auth\Controller\AuthController',
        'Auth\Controller\Success' => 'Auth\Controller\SuccessController',
    ),
),   
'router' => array(
    'routes' => array(
        'auth' => array(
            'type' => 'segment',
            'options' => array(
                'route'    => '/auth[/:action][/:id]', 
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',  
                    'id'=>'[0-9a-zA-Z]*',                        
                ),
                'defaults' => array(
                    'controller' => 'Auth\Controller\Auth',
                    'action'     => 'index',

                ),
            ),
        ),
        'success' => array(
            'type' => 'segment',
            'options' => array(
                'route'    => '/success[/:action]', 
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',

                ),
                'defaults' => array(
                    'controller' => 'Auth\Controller\Success',
                    'action'     => 'index',

                ),
            ),
        ),
    ),

),

'view_manager' => array(
    'template_path_stack' => array(
        'auth' => __DIR__.'/../view',
    ),
),

);