2010-01-16 68 views
0

我有一个.htaccess文件看起来像这样:Zend框架控制器加载失败之谜

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] 

如果我浏览到我的网站我有,测试说http://www.example.com/,索引页加载正确。

这是Zend框架应用程序,因此它应该路由的事情了我的控制器,因为它不正确,如果我去http://www.example.com/index/indexhttp://www.example.com/index,指定控制器+动作,只是在控制器。

如果我做了一些像http://www.example.com/index/test这样的工作,我在索引控制器上定义了另一个名为test的动作。

但是,如果我做一个TestController.php文件,并试图去http://example.com/test/,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> 

有人能看到我在这里搞砸了?

Billy3

编辑:我的网站的配置看起来像:

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> 

回答

0

事实证明,如果你的网站是不是域的根,你必须为了增加RewriteBase指令,以便正确格式化的东西。我仍然不知道为什么事先报告了正确的文件,但似乎现在起作用。

感谢,并有一个愉快的一天:)

1

时的mod_rewrite不工作,我通常遇到了这个问题。

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

+0

如果mod_rewrite并没有,为什么'HTTP:// www.example.com /索引/ index'正常工作?为什么'/ path/to/website/root/public/index.php'存在,尽管Apache抱怨相反? – 2010-01-17 02:16:17

+0

编辑我的问题 - AllowOverride所有列出:( – 2010-01-17 02:27:30

+0

有趣的 - 如果我关闭'.htaccess'中的'MultiViews'选项,那么甚至没有'http:// www.example.com/index/index'工作正常。我怀疑我的index.php在这一点上有一些权限问题。 – 2010-01-17 03:19:30

0

所以,如果我正确读取这个,路由工作正常,但不是当你只指定在url中的控制器。

所以,你有以下几点:

class TestController extends Zend_Controller_Action 
{ 

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

    } 

} 
+0

是的,请注意,错误信息是由Apache生成的 - 而不是Zend Framework。 – 2010-01-19 05:11:21