doushaiyu5065 2015-11-25 22:09
浏览 44
已采纳

Zend Framework 2路由无法正常运行Windows 7

I read all the questions posted here and can´t find solution to my problem.

I have windows 7, xampp, apache 2.4, php 5.6, zend framework 2

I created a sample application named Application

This is my .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]

My config files looks like this

   '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/ this works

localhost:8080/lizziap/Index this doesnt works

localhost:8080/lizziap/Login this doesnt works

localhost:8080/Index this doesnt works

Page not found. The requested URL could not be matched by routing.

No Exception available

I will really appreciate any help ... THANKS!

This is how config looks now and it works

'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',
                ),
            ),
        ),
  • 写回答

1条回答 默认 最新

  • douxuanpa8298 2015-11-25 22:37
    关注

    Maybe my config file will help you:

    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',
        ),
    ),
    
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序