John Cogan
John Cogan

Reputation: 41

Zend Framework - A link to images causing issue with rewrite rules

I have an issue in that I am trying to simply display an image within my images folder in a new window via an anchor link with target=blank.

I added the rewrite rule to the public folders .htaccess as explained in the post at : Zend keep front controller from blocking image requests but it is still giving me the error as below and cannot figure out why.

All other images used in the pages display fine, its only the images that are linked as:

<a href="/images/balloon.jpeg" target="_blank">Balloon</a> 

The exception message is

Exception information:

Message: Invalid controller specified (images)
Stack trace:

#0 /home/euphoria/public_html/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /home/euphoria/public_html/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#2 /home/euphoria/public_html/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 /home/euphoria/public_html/public/index.php(25): Zend_Application->run()
#4 {main}  

Request Parameters:

array (
'controller' => 'images',
'action' => 'profile_uploads',
'module' => 'default',
)  

My public folder .htaccess is

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]

I have another .htaccess file within my images folder to stop php executions via the use of images files and its contents is

php_flag engine off

The above issue with Zend trying to redirect to an 'images' controller only started occuring when I added the above .htaccess to the images folder.

The problem disappears when I remove the .htaccess that has the "php_flag engine off" rule

The images and its folder are CHMOD 777 and the site is in its own domain on a shared hosting env. (As opposed to sub domain)

Many thanks

Upvotes: 1

Views: 525

Answers (1)

Sven
Sven

Reputation: 70853

And you are sure that there is a folder "images" in your DOCUMENT_ROOT folder, and that it contains an image named "balloon.jpeg"?

The second rewrite rule essentially is useless.

  1. It does not detect your "jpeg" image, it would only detect a "jpg" image.
  2. This rule will only ever be reached if the first rule and all the RewriteCond lines cannot detect that your requested resource is an actual existing file on the server.
  3. The third rule will ultimately take place nonetheless, because the second rule is not marked as the "last rule evaluated".

Throw it out. The standard rewriting for Zend framework works. If it does not in your case, you did something wrong, most likely you did not place your image where it belongs.

Upvotes: 1

Related Questions