Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法路由除'/';在Zend框架2中_Php_Apache_Zend Framework2_Zend Server - Fatal编程技术网

Php 无法路由除'/';在Zend框架2中

Php 无法路由除'/';在Zend框架2中,php,apache,zend-framework2,zend-server,Php,Apache,Zend Framework2,Zend Server,我将Zend Framework 2与Zend Studio 10和Zend Server一起使用。 框架应用程序运行正常,但除“/”之外的任何内容也无法路由,它只返回“此服务器上未找到请求的URL” 这是module.config,它几乎与骨架相同,只是我在路径“/lol”上添加了一个控制器“Foo”,其中有一个操作“lol”,但它不起作用 <?php /** * Zend Framework (http://framework.zend.com/) * * @link

我将Zend Framework 2与Zend Studio 10和Zend Server一起使用。 框架应用程序运行正常,但除“/”之外的任何内容也无法路由,它只返回“此服务器上未找到请求的URL”

这是module.config,它几乎与骨架相同,只是我在路径“/lol”上添加了一个控制器“Foo”,其中有一个操作“lol”,但它不起作用

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

return array(
    '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'    => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/lol',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Application\Controller',
                        'controller'    => 'Foo',
                        'action'        => 'lol',
                    ),
                ),
                '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(
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
        ),
    ),
    '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\Index' => 'Application\Controller\IndexController',
            'Application\Controller\Foo'   => 'Application\Controller\FooController',

        ),
    ),
    'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
);

是什么引起的?

我通过配置Zend apache2服务器并将“AllowOverride None”设置为“AllowOverride All”解决了这个问题。我不知道为什么它会有帮助,如果有人指出这一点,我会很高兴。

我通过配置Zend apache2服务器并将“AllowOverride None”设置为“AllowOverride All”解决了这个问题。我不知道为什么会有帮助,如果有人指出这一点,我会很高兴。

你检查过了吗。htaccess被解析(或者如果你不使用Apache,甚至可以解析)或者VHOST被相应地配置了?我该怎么做?(我正在使用Zend Server部署)Zend Server基于Apache,默认情况下配置为解析.htaccess,因此Web服务器端不会出现任何问题。检查是否部署了.htaccess。是否检查了.htaccess是否已解析(如果您不使用Apache,甚至可以解析),或者VHOST是否已相应地配置?我如何才能做到这一点?(我正在使用Zend Server部署)Zend Server基于Apache,默认情况下配置为解析.htaccess,因此Web服务器端不会出现任何问题。检查.htaccess是否已部署。
AllowOverride None
不允许您通过htaccess覆盖任何设置,而
AllowOverride All
允许您覆盖任何配置值(可由htaccess覆盖)。因此,无法设置重写规则,因为不允许这样做-它们只是被忽略了。感谢您的澄清可以帮助我如何允许此允许覆盖所有,我在virutal主机中这样做了,但没有成功
allowveride None
不允许您通过htaccess覆盖任何设置,而
AllowOverride All
允许您覆盖任何配置值(可由htaccess覆盖)。因此,无法设置重写规则,因为不允许这样做-它们只是被忽略。感谢您的澄清可以帮助我如何允许此允许覆盖所有内容,我在虚拟主机中执行了此操作,但未成功
[Mon Jan 07 14:45:58 2013] [error] [client 127.0.0.1] File does not exist: C:/Program Files (x86)/Zend/ZendServer/data/apps/http/__default__/0/Test/1.0.0/public/lol
[Mon Jan 07 14:46:03 2013] [error] [client 127.0.0.1] File does not exist: C:/Program Files (x86)/Zend/ZendServer/data/apps/http/__default__/0/Test/1.0.0/public/lol