2010-04-29 86 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