Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework 使用Zend Framework将图像记录为404_Zend Framework_.htaccess_Url Rewriting - Fatal编程技术网

Zend framework 使用Zend Framework将图像记录为404

Zend framework 使用Zend Framework将图像记录为404,zend-framework,.htaccess,url-rewriting,Zend Framework,.htaccess,Url Rewriting,由于Zend将URL重写为module/controller/action,它报告说图像将以404的形式通过 以下是错误: [_requestUri:protected] => /images/Movie/124/thumb/main.png [_baseUrl:protected] => [_basePath:protected] => [_pathInfo:protect

由于Zend将URL重写为module/controller/action,它报告说图像将以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
这是我的访问权限

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


想法?

如果您使用默认目录结构,当您将图像放在./public文件夹中时,它应该起作用。

如果您使用默认目录结构,当您将图像放在./public文件夹中时,它应该起作用。

将图像文件夹放在您的公共位置中,正如Arnie提到的那样,您很好。这同样适用于您可能希望在任何视图中包含的任何其他文件,例如CSS文件

/public
   |__ images/
   |__ css/
干杯。
M.

将您的图像文件夹放在您的公共位置,正如阿尼所说,您可以开始了。这同样适用于您可能希望在任何视图中包含的任何其他文件,例如CSS文件

/public
   |__ images/
   |__ css/
干杯。
你可以试试这个片段

 <img src="<?=$this->baseUrl('/img/icon_quickstart.png');?>" alt="start" />
baseUrl('/img/icon_quickstart.png');?>“alt=”开始“/>

您可以试试这个片段

 <img src="<?=$this->baseUrl('/img/icon_quickstart.png');?>" alt="start" />
baseUrl('/img/icon_quickstart.png');?>“alt=”start“/>

您可以使用

RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php

witch应该让图像和其他东西通过。

您可以尝试使用

RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php

witch应该让图像和其他东西通过。

我在Zend项目中使用相同的.htaccess和setup,但我没有看到这种行为

只是一些可能会让你走上正确道路的想法:

  • 路径中的区分大小写
  • 路径实际上不存在,导致Apache传递到index.php
  • Apache配置(全局)或虚拟主机级别
  • 权限问题?发出请求时,./public/main.png处的main.png是否呈现
  • application.ini中的重叠路由模式
  • 禁用.htacces一段时间,只是为了看看它是否正确映射了目录
只是一些想法。
-andrew

我在Zend项目中使用相同的.htaccess和setup,但没有看到这种行为

只是一些可能会让你走上正确道路的想法:

  • 路径中的区分大小写
  • 路径实际上不存在,导致Apache传递到index.php
  • Apache配置(全局)或虚拟主机级别
  • 权限问题?发出请求时,./public/main.png处的main.png是否呈现
  • application.ini中的重叠路由模式
  • 禁用.htacces一段时间,只是为了看看它是否正确映射了目录
只是一些想法。
-andrew

您在那里设置的.htaccess重写规则的逻辑是,如果找不到该文件,它会将请求发送到index.php。这意味着,如果您的图像无法访问(不在公共目录中),zend_框架将尝试处理它。当然它不能。您在那里设置的.htaccess重写规则的逻辑是,如果它找不到文件,它会将请求发送到index.php。这意味着,如果您的图像无法访问(不在公共目录中),zend_框架将尝试处理它。当然它不能。你必须添加行

RewriteCond %{REQUEST_FILENAME} -f

你必须加一行

RewriteCond %{REQUEST_FILENAME} -f