Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.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框架控制器负载故障之谜_Php_Zend Framework - Fatal编程技术网

Php Zend框架控制器负载故障之谜

Php Zend框架控制器负载故障之谜,php,zend-framework,Php,Zend Framework,我有一个.htaccess文件,看起来像这样: SetEnv APPLICATION_ENV development RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L

我有一个
.htaccess
文件,看起来像这样:

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
如果我浏览到我正在测试的站点,比如说,正确加载索引页面

这是一个Zend Framework应用程序,因此它应该将内容路由到我的控制器,如果我转到或,分别指定控制器+操作,并且仅指定控制器,它就会正确地路由到我的控制器

如果我在索引控制器上定义了另一个名为test的操作,它也可以工作

但是,如果我创建一个
TestController.php
文件,并尝试转到,Apache将返回:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html><head> 
<title>404 Not Found</title> 
</head><body> 
<h1>Not Found</h1> 
<p>The requested URL /path/to/website/root/public/index.php was not found on this server.</p> 
<hr> 
<address>Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.4.6 PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch Phusion_Passenger/2.0.3 mod_perl/2.0.3 Perl/v5.8.8 Server at www.example.com Port 80</address> 
</body></html> 

404找不到
找不到
在此服务器上找不到请求的URL/path/to/website/root/public/index.php。


Apache/2.2.8(Ubuntu)DAV/2 SVN/1.4.6 PHP/5.2.4-2ubuntu5.10,带有Suhosin补丁Phusion_Passenger/2.0.3 mod_perl/2.0.3 perl/v5.8.8服务器,位于www.example.com端口80
有人知道我搞砸了什么吗

比利3

编辑:“我的网站”的配置如下所示:

Alias /MySiteRoot/ "/usr/local/vsites/something/www/"
<Directory /usr/local/vsites/something/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
Alias/MySiteRoot/“/usr/local/vsites/something/www/”
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融

我通常在mod_rewrite不起作用时遇到这个问题


如果已启用mod_rewrite,请在/etc/apache2/sites available/yoursite.com配置文件中检查AllowOverride是否设置为All。

因此,如果我正确阅读了此内容,则路由工作正常,但仅在url中指定控制器时则无法正常工作

所以你有以下几点:

class TestController extends Zend_Controller_Action
{

    //do you have an index action???
    public function indexAction()
    {

    }

}

事实证明,如果您的站点不是域的根,则必须添加RewriteBase指令才能正确格式化内容。我仍然不知道为什么它事先报告了正确的文件,但它现在似乎起作用了


谢谢,祝你今天愉快:)

如果mod_rewrite不起作用,为什么
http://www.example.com/index/index
工作正常吗?尽管Apache抱怨相反,为什么
/path/to/website/root/public/index.php
仍然存在?编辑我的问题——AllowOverride All列出:(有趣的是——如果我关闭
.htaccess
中的
多视图
选项,那么甚至
http://www.example.com/index/index
工作正常。我怀疑此时我的index.php上存在某种权限问题。-rw-rw-r--1 subversion subversion 754 2010-01-16 22:09 index.phpI没有设置Web服务器。是的,我还要注意,错误消息是由Apache生成的,而不是由Zend框架生成的。