php – Zend Framework:在此服务器上找不到请求的URL / my / path

栏目: PHP · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/8374833/zend-framework-the-requested-url-my-path-was-not-found-on-this-server

我是Zend Framework的新手.

我写了一个简单的Web服务,它使用Zend Framework返回模拟XML数据,模块结构如下:

AppName
    application
        configs
            application.ini
        modules
            default
                .....
            api
                controller
                    CatalogController.php
                view
        library
        public
            .htaccess
            index.php
        tests

在localhost(Windows 7)中,这些正在运行:

http://localhost

http://localhost/api/catalog

http://localhost/default

在我的生产服务器(linux)中,我从’找不到’404文件’:

http://107.22.255.126/api/catalog

http://107.22.255.126/default

但这很有效

http://107.22.255.126

我在Amazon Web Services中托管它.

这是我的.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]

这是我的application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
//resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = "default"
resources.modules[] = "api"
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
resources.layout.layout = master

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

这是我的Bootstrap.php

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    protected function _initRoutes()
    {
        $front = Zend_Controller_Front::getInstance();
        $router = $front->getRouter();
        $restRoute = new Zend_Rest_Route($front, array(), array('api'));
        $router->addRoute('api', $restRoute);
    }

}

?>

我已经没想完了.我怀疑这与bootstraper中的路由器有关,但找不到任何解决方案.

最后,问题是因为httpd.conf禁用了.htaccess目录.我在VirtualHost下添加了AllowOverride All,它可以正常工作.

像这样:

<VirtualHost *:80>
    DocumentRoot "var/www/html/TestMVC/public"

    <Directory "var/www/html/TestMVC/public">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>

在问题的评论中归功于@Corbin.

翻译自:https://stackoverflow.com/questions/8374833/zend-framework-the-requested-url-my-path-was-not-found-on-this-server


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Art of Computer Programming, Volume 4,  Fascicle 3

The Art of Computer Programming, Volume 4, Fascicle 3

Donald E. Knuth / Addison-Wesley Professional / 2005-08-05 / USD 19.99

Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 4, Fascicle 3》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具