1

我希望能够单击图像并将其重定向到另一个 html 页面。此页面不存储在网站目录根目录中。我尝试了以下代码,但出现 404 错误。

<a href="/home/tyler/Documents/hfm/website/index.html"><img src= "fahlogo.png" /></a>
4

2 回答 2

2

编辑

Apache 的Alias允许您将其他文件路径映射到 Web 路径。例如:

Alias /mydocs /home/tyler/Documents/hfm/website

这将告诉 apache 提供/mydocs/index.html在 /home/tyler/Documents/hfm/website/index.html 下查看的请求。那么你可以使用:

<a href="/mydocs/index.html"><img src= "fahlogo.png" /></a>

使用相对 URL:

<a href="/index.html"><img src= "fahlogo.png" /></a>

这将指向http://mywebsite.com/index.html. 如果你需要,说,http://mywebsite.com/app/index.html那么你会使用:

<a href="/app/index.html"><img src= "fahlogo.png" /></a>
于 2013-10-11T20:00:48.357 回答
0

如果文件位于当前文件夹的正上方,只是提示,您可以通过将“../”放在文件名前面来告诉浏览器向上移动一个文件夹。例子:

<a href="../index.html"><img src= "fahlogo.png" /></a>
于 2013-10-11T20:55:12.457 回答