了解文件夹“图像”作为控制器

发布于 2024-09-07 11:59:10 字数 821 浏览 4 评论 0原文

当我尝试访问 url http://localhost/mysite/public/images/grey 时-arrow.gif 在我的应用程序的控制器中,我收到错误:

致命错误:未捕获异常“Zend_Controller_Dispatcher_Exception”,消息“指定的控制器(图像)”在 C:\xampp\php\PEAR\Zend\Controller 中\Dispatcher\Standard.php:242 堆栈跟踪: #0 C:\xampp\php\PEAR\Zend\Controller\Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) # 1 D:\Users\rnem\www\mysite\application\Bootstrap_Aplicativo.php(64): Zend_Controller_Front->dispatch() #2 D:\Users\rnem\www\regnet3.0\home\index.php(3 ): include_once('D:\Users\rnem\w...') #3 {main} 在第 242 行 C:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php 中抛出

为什么它在思考images 是一个控制器而不是一个文件夹?!

When I try to access the url http://localhost/mysite/public/images/grey-arrow.gif in a controller in my application I get the error:

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (images)' in C:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php:242 Stack trace: #0 C:\xampp\php\PEAR\Zend\Controller\Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 D:\Users\rnem\www\mysite\application\Bootstrap_Aplicativo.php(64): Zend_Controller_Front->dispatch() #2 D:\Users\rnem\www\regnet3.0\home\index.php(3): include_once('D:\Users\rnem\w...') #3 {main} thrown in C:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php on line 242

Why is it thinking images is a controller instead of a folder as it is?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

深居我梦 2024-09-14 11:59:10

/public 中的 .htaccess 文件中有什么?

What do you have in your .htaccess file in /public?

狼性发作 2024-09-14 11:59:10

这就是我所拥有的

# Rewrite rules for Zend Framework
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

# Security: Don't allow browsing of directories
Options -Indexes

This is what I have

# Rewrite rules for Zend Framework
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

# Security: Don't allow browsing of directories
Options -Indexes
浮华 2024-09-14 11:59:10

我认为您可能需要通过虚拟主机配置访问您的站点,而不是仅仅通过 localhost 进行路径访问。我怀疑 URL 重写器无法找到您的图像文件,因为它不知道 public 是提供文件的根目录,因此它会尝试将 URL 解释为控制器动作。

Zend Framework 快速入门

I think you might need to access your site via a virtual host configuration, instead of just path-ing out via localhost. I suspect the URL re-writer can't find your image file because it doesn't know that public is the root directory files are served from, so it falls back on trying to interpret the URL as a controller action.

Creating a virtual host is covered in the Zend Framework Quickstart

〆凄凉。 2024-09-14 11:59:10

zend 的默认 htaccess 是:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

Give that a go。如果这不起作用,上面提到的虚拟主机应该是:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/Users/rnem/www/mysite/public
</VirtualHost>

将其放入您的虚拟主机conf文件中,请记住取消注释httpd.conf中的虚拟主机行。这可能会有所帮助,http://www.tildemark.com/software/servers/setting-up-virtual-hosts-with-xampp-running-on-windows-xp.html,否则谷歌上有很多指导

The default htaccess for zend is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

Give that a go. If that doesn't work the vhosts mentioned above should be:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/Users/rnem/www/mysite/public
</VirtualHost>

Put that into your vhosts conf file, remember to uncomment the vhosts line in your httpd.conf. This might help, http://www.tildemark.com/software/servers/setting-up-virtual-hosts-with-xampp-running-on-windows-xp.html, otherwise there's plenty of giudes on google

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文