我如何在本地寻址 <img> 而无需 xampp 将本地主机添加到图像地址

How can I locally address an <img> without xampp prepending localhost to the image address

我在本地使用 Xampp 到 运行 php 目录结构如下:

D:/LaunchBox/mySoftware/xampp-project/index.php

我正在尝试显示 HTML 位于此处的图像:

D:/LaunchBox/Images/Platforms/myImage.png

所以我的标签是:

<img src="D:/LaunchBox/Images/Platforms/myImage.png">

图片未显示。如果我在 Chrome 中使用“检查”时将鼠标悬停在图像地址上,我会看到以下地址:

http://localhost/D:/LaunchBox/Images/Platforms/myImage.png

我试过只使用 ../Images/etc 但无济于事。

我确定我遗漏了一些简单的东西,但我被卡住了?有人有什么想法吗?

好的,我已经破解了。以防万一其他人有类似的问题,这就是我所做的。我在 Xampp following the instructions here

中设置了虚拟主机

然后我在 xampp\apache\conf\extra\httpd-vhosts.conf

中用以下内容解决了我的软件
<VirtualHost *:80>
DocumentRoot "D:\LaunchBox"
ServerName arcade-project.com
<Directory "D:\LaunchBox">
</Directory>
</VirtualHost>

我现在可以使用 URL arcade-project.com

访问我的项目

而且,在我的代码中,我可以通过使用相对 URL 来显示图像,例如:

./Images/Platforms/myImage.png