【发布时间】:2021-07-27 00:47:39
【问题描述】:
由于某种原因,当我在 hostgator 索引文件(public_html 下)中引用 CSS 文件或图像文件时,它们不起作用,但当我在本地测试时它就起作用了。这是我尝试使用通过 cPanel 上传到 public_html 文件夹的图像的示例:
<!DOCTYPE html>
<html>
<head>
<title>mydomain.com</title>
</head>
<h1>Here is an image</h1>
<img src="public_html/me.JPG" alt="pic of me">
<p style="background-color:#ECEBE9;">Here is more text
</p>
</body>
</html>
我试过了:
- 更改权限(public_html 中的所有内容都是 755 和 public_html 是 750 as per hostgator's instructions)
- 使用完整路径:“/home/username/public_html/”(使用我的用户名并尝试使用“home3”而不是“home”)
- 将 JPG 放入名为 images 的子文件夹中并使用该路径名
我假设路径很明显,但我真的不明白为什么 index.html 文件无法访问 hostgator 上同一文件夹中的 CSS 或图像文件,所以请让我知道还有什么可以尝试的.
【问题讨论】:
标签: html css path localhost cpanel