首页 > 解决方案 > xampp没有加载图像

问题描述

图像未加载到 xammp 包中。

我的 apache 虚拟主机配置:

<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\shop.local"
    ServerName shop.local
    ErrorLog "logs/shop.local-error.log"
    CustomLog "logs/shop.local-access.log" common
</VirtualHost>

我的目录结构:

 - public
   - .htaccess
   - index.php
   - errors
     - 404.php
     - images
       - 404.png
 - vendor
 - .htaccess

根目录中的 htaccess:

AddDefaultCharset utf-8
RewriteEngine On
RewriteRule (.*) public/$1

公共目录中的 htaccess:

RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule (.*) index.php?$1 [L,QSA]

index.php 文件:

<?php
require dirname(__DIR__) . '/public/errors/404.php';

404.php 文件:

<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div class="wrap">
    <div class="logo">
        <img src="/errors/images/404.png">
    </div>
</div>
</body>
</html>

阿帕奇日志:

127.0.0.1 - - [15/Sep/2019:01:35:14 +0300] "GET /public/errors/404.png HTTP/1.1" 200 141

标签: phpimagexamppserve

解决方案


我只是在 .htaccess 中写错了条件

RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d

适当地:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

推荐阅读