【问题标题】:Understanding folder "image" as a controller将文件夹“图像”理解为控制器
【发布时间】:2010-06-28 14:14:58
【问题描述】:

当我尝试在应用程序的控制器中访问 url http://localhost/mysite/public/images/grey-arrow.gif 时,出现错误:

致命错误:C:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php:242 堆栈跟踪:#0 C:\ xampp\php\PEAR\Zend\Controller\Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 D:\Users\rnem\www\mysite\application\Bootstrap_Aplicativo.php (64): Zend_Controller_Front->dispatch() #2 D:\Users\rnem\www\regnet3.0\home\index.php(3): include_once('D:\Users\rnem\w...') #3 {main} 在第 242 行的 C:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php 中抛出

为什么它认为图像是控制器而不是文件夹?!

【问题讨论】:

    标签: zend-framework controller


    【解决方案1】:

    您在 /public 中的 .htaccess 文件中有什么?

    【讨论】:

    • 确实,当您的 RewriteRules 匹配所有请求或匹配与磁盘上的文件不对应的请求时,就会发生这种情况
    【解决方案2】:

    这就是我所拥有的

    # Rewrite rules for Zend Framework
    RewriteEngine on
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1
    
    # Security: Don't allow browsing of directories
    Options -Indexes
    

    【讨论】:

      【解决方案3】:

      我认为您可能需要通过虚拟主机配置访问您的站点,而不仅仅是通过localhost 进行路径输出。我怀疑 URL 重写器找不到您的图像文件,因为它不知道 public 是提供文件的根目录,因此它试图将 URL 解释为控制器操作。

      Zend Framework Quickstart 中介绍了创建虚拟主机

      【讨论】:

        【解决方案4】:

        zend 的默认 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]
        

        试一试。如果这不起作用,上面提到的虚拟主机应该是:

        NameVirtualHost *:80
        
        <VirtualHost *:80>
        ServerName localhost
        DocumentRoot D:/Users/rnem/www/mysite/public
        </VirtualHost>
        

        把它放到你的 vhosts conf 文件中,记得在你的 httpd.conf 中取消注释 vhosts 行。这可能会有所帮助,http://www.tildemark.com/software/servers/setting-up-virtual-hosts-with-xampp-running-on-windows-xp.html,否则谷歌上有很多指南

        【讨论】:

          猜你喜欢
          • 2023-03-20
          • 1970-01-01
          • 1970-01-01
          • 2012-10-18
          • 1970-01-01
          • 1970-01-01
          • 2015-09-14
          • 1970-01-01
          • 2021-10-16
          相关资源
          最近更新 更多