2010-04-29 94 views
1

由于Zend的重写URL对模块/控制器/动作,它的报告,以图像来通过为404影像记录与Zend框架404

以下是错误:

[_requestUri:protected] => /images/Movie/124/thumb/main.png 
       [_baseUrl:protected] => 
       [_basePath:protected] => 
       [_pathInfo:protected] => /images/Movie/124/thumb/main.png 
       [_params:protected] => Array 
        (
         [controller] => images 
         [action] => Movie 
         [124] => thumb 
         [module] => default 
        ) 

       [_rawBody:protected] => 
       [_aliases:protected] => Array 
        (
        ) 

       [_dispatched:protected] => 1 
       [_module:protected] => default 
       [_moduleKey:protected] => module 
       [_controller:protected] => images 
       [_controllerKey:protected] => controller 
       [_action:protected] => Movie 
       [_actionKey:protected] => action 

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

我想我需要什么待办事项放在某种形象或/设计检测所以它不是路由到index.php

想法?

回答

1

您设置的.htaccess重写规则的逻辑是,如果它找不到该文件,它会将请求发送到index.php。这意味着如果您的图片无法访问(不在公共目录中),zend_framework将尝试处理它。它当然不能。

1

如果您使用默认的目录结构,它应该在将图像放入./public文件夹时起作用。

0

将你的图片文件夹放在你的公共位置,正如阿尼提到你很好去。您可能希望包含在任何视图中的任何其他文件也是如此,例如CSS文件。

/public 
    |__ images/ 
    |__ css/ 

干杯。 M.

+1

他们在公共/图片 – azz0r 2010-04-30 09:13:22

0

你可以试试这个片断

<img src="<?=$this->baseUrl('/img/icon_quickstart.png');?>" alt="start" /> 
1

你可以尝试起了变化你的htaccess与

RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php 

巫shoudl让图片和其他的东西去通。

0

我使用相同的.htaccess和设置为一个Zend项目,但没有看到这种行为。

只是一些想法,可能会送你沿着正确的路径:

  • 区分大小写的路径?
  • 路径实际上并不存在,导致Apache传递给index.php?
  • Apache配置(全局)或VirtualHost级别
  • 权限问题?在提出请求时,是否在./public/main.png的main.png呈现?
  • application.ini内重叠的路由模式?
  • 禁用.htacces了一下,看看它是否正确映射目录?

只是一些想法。 -andrew

1

您必须添加行

RewriteCond %{REQUEST_FILENAME} -f