【问题标题】:IndexController not found in ZendFramework在 ZendFramework 中找不到 IndexController
【发布时间】:2014-09-23 08:22:40
【问题描述】:

我用两个控制器 Index 和 Admin 创建了一个新的 ZendFramework 项目。

我还为这个站点创建了虚拟主机。这是我的网站。/etc/apache2/sites-enebled/site.home.conf

<VirtualHost *:80>
SetEnv APPLICATION_ENV development
DocumentRoot /home/user/server/site/public/
ServerName site.home
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory /home/user/server/site/public/>
    Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Require all granted
</Directory></VirtualHost>

这是我的 ~/server/site/public/.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]

一切看起来都很好,因为通常它是我在同一服务器上的另一个项目的副本,但是(!)我有下一个服务器行为:

http://site.home - OK (code 200)
http://site.home/index or http://site.home/index/index - page not found (code 404 from Apache)
http://site.home/Index (with capital I) - OK (code 200)
http://site.home/admin or http://site.home/admin/index - OK (code 200)

所以只有当我调用“索引”控制器时才会出现问题。如何解决?

更新 我找到了解决方法。我在 /public 中创建了一个“索引”文件夹,http://site.home/index 工作正常! 但我认为这不是一个解决方案...

【问题讨论】:

  • 检查你的IndexController的类名是否正确。
  • 是的,它是自动创建的
  • @lubart 如何以原子方式创建,zf 工具?
  • 启用错误,然后向我们显示错误:将 resources.frontcontroller.params.displayExceptions = 1phpSettings.display_errors = 1 添加到您的 ini 配置中
  • 感谢您的回复。项目是由 NetBeans 通过 zf 工具创建的。我从服务器(404 Not Found)而不是 zf 获得错误。但是@Tim Fountain 已经为我提供了一个很好的建议:)

标签: apache .htaccess zend-framework virtualhost


【解决方案1】:

从您的虚拟主机中删除 MultiViews 选项,然后我认为它应该可以正常工作。 &lt;Directory /&gt; ... &lt;/Directory&gt; 部分是不必要的,也可以删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-18
    • 2015-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    相关资源
    最近更新 更多