0

Anytime I use an <img> tag in my Zend Framework application, no image is displayed. When I type the absolute path into the address bar, the front controller attempts to find an "images" controller.

There HAS to be a way I can use <img src="/public/images/logo.png"> in Zend Framework right?

I've tried it from within views, layouts, and helpers, and no luck. I've also used the $this->baseURL() technique, and the serverURL() technique by getting the info from the Front Controller, but it still won't show the image... anywhere on the site. (I have the same problem with including css files unless I do an @import('/css/main.css')

Brian Vanderbusch
  • 3,313
  • 5
  • 31
  • 43

1 Answers1

2

Sounds like an problem with your .htaccess file you have to exclude this files from the reWrite rule, otherwise those requests are routed to index.php.

/public/.htaccess

RewriteEngine on
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php
opHASnoNAME
  • 20,224
  • 26
  • 98
  • 143
  • This is almost certainly the answer. Your web server (and not ZF) should be configured to serve static files instead of rewriting the URLs to index.php. – timdev May 04 '12 at 04:17
  • so I guess that Rewrite Rule mean's DON'T route requests with an extension (of those types) to index.php? I did see that in the documentation, but I thought it meant route any request of type (etc...) to index.php – Brian Vanderbusch May 04 '12 at 05:12
  • Also, according to Zend's documentation, it shouldn't route anything under the document_root (anything in the /public folder) to the Rewrite Anyways? I plugged the above line into the .htaccess file, not getting results. Here's my file now: `SetEnv APPLICATION_ENV development RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php RewriteRule ^.*$ index.php [NC,L]` – Brian Vanderbusch May 04 '12 at 05:22