XAMPP上的CodeIgniter-403/404访问图像时出错


CodeIgniter on XAMPP - 403/404 Error accessing images

我真的很难理解为什么我不能在XAMPP上的本地Codeigniter安装中加载任何图像。

我在application文件夹中放入了一个img文件夹,其中只包含一个名为arrow.png的图像,但我无法访问它,也无法在视图中显示它。

我怀疑这可能是一个.htaccess问题,但我尝试了不同的解决方案,但没有成功。这就是我现在拥有的:

Options FollowSymLinks
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond $1 !^(index'.php|robots'.txt|assets|cache|themes|uploads)
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

在我的配置PHP中,我当然编辑了:

$config['index_page'] = '';

在我名为ordine.php的视图中,我这样称呼我的图像:

<img src="<?php echo base_url("img/arrow.png"); ?>" title="Go to Top" alt="Go to Top"/>

生成的URL似乎是正确的,但图像没有显示。如果我直接点击那个链接,我会得到一个404错误。

http://localhost/clientname/img/arrow.png

编辑:它可能是我的httpd.conf apache文件中的内容,设置如下吗?

Alias /bitnami/ "/Applications/XAMPP/xamppfiles/apache2/htdocs/"
Alias /bitnami "/Applications/XAMPP/xamppfiles/apache2/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

提前感谢您对此提出的任何建议和帮助。

经过艰苦的搜索,我自己已经解决了这个问题。事实证明,这一切都是OS X权限,不允许我查看特定子文件夹中的图像。我必须做的事写在这篇文章上。

感谢任何努力帮助我的人——对于这种问题,无论是本地操作系统问题还是网络服务器问题,都很难理解。

检查您的htaccess文件。是否允许在网页中加载图像。在这里我会放一个工作的htaccess文件。试试看…

RewriteBase /clientname/
RewriteEngine on
RewriteCond $1 !^(index'.php|resources|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

您也可以参考这里的一个论坛,该论坛讨论了CI无法显示图像

         <?php echo base_url("/img/arrow.png"); ?>

试试这个。