Reputation: 20726
(Possible it works as designed, but I'm sure it was working before updating to ZF 1.11.x.)
I am trying to "print" an image to the browser, but when I construct the URL like this:
webserver/index/get-image/PARAM1/xyz/IMAGE/1.jpg
I get a 404 error from the server
webserver/index/get-image/IMAGE/1.jpg/PARAM1/xyz
Works..
Any ideas?
Upvotes: 1
Views: 195
Reputation: 1774
The 404-error is most likely because you've defined in the web server rules (e.g. .htaccess) that urls ending with .jpg should not be rewritten to index.php (e.g. RewriteRule ^[\w/\%]*(?:\.(?!(?:js|ico|gif|jpg|png|css|html)$)[\w\%]*$)? /index.php [I]
)
When using Apache, the following should work:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
For more information, go to http://framework.zend.com/manual/en/zend.controller.router.html
Upvotes: 2
Reputation:
Try Zend_Route as follows
$route = new Zend_Controller_Router_Route(
'images/:img',
array(
'controller' => 'index',
'action' => 'getImageAction'
)
);
$router->addRoute('user', $route);
and now when you go to server/images/pic1.jpg, you will have a param (retrieve through $this->getRequest->getParam('img')
from you Controller) available for whatever you wish for. GL
EDIT: I see now this wasn't your problem exactly, but this might be a fruitful workaround anyhow.
Upvotes: 0
Reputation: 1
Actually, there is one more difference in the two urls and it is the get-image action (I assume it is an action if it is ZF). Try to add or remove the action also on the second link and post back the results.
Upvotes: 0