Zend阻止前端控制器阻止图像请求 [英] Zend keep front controller from blocking image requests
问题描述
每当我在Zend Framework应用程序中使用<img>
标记时,都不会显示图像.当我在地址栏中输入绝对路径时,前端控制器会尝试找到图像"控制器.
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.
有一种方法可以在Zend Framework中使用<img src="/public/images/logo.png">
吗?
There HAS to be a way I can use <img src="/public/images/logo.png">
in Zend Framework right?
我从视图,布局和助手中进行了尝试,但是没有运气.我还通过从Front Controller获取信息来使用$this->baseURL()
技术和serverURL()
技术,但是它仍然不会在站点上的任何位置显示图像. (除非我执行@import('/css/main.css')
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')
推荐答案
听起来像您的.htaccess文件有问题 您必须从reWrite规则中排除此文件,否则这些请求将路由到index.php.
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
这篇关于Zend阻止前端控制器阻止图像请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!