href="../" 链接到根目录而不是父目录

href="../" links to root instead of parent directory

我正在编写一个简单的 Web 服务器并进行一些目录遍历,并且在每个目录中我都包含一个 link 到父目录以便返回。

然而,无论我在目录树中的深度如何,当我创建父级 link(在我的 link 中使用 href="../")时,它会直接返回到根.

例如:
- 我在 localhost:2345/dir1/dir2/dir3/dir4
- HTML 页面显示 links 到 dir4 中的文件和目录,包括父级
- "parent" linked (<\a>) with (href="../")
- 点击 "parent" --> 指向 localhost:2345/

以下是我会尝试做的几件事: (1) 检查网络服务器重定向设置 (2) Web 服务器是否需要文件扩展名(例如 .html .htm)才能正确加载页面?如果父目录的根文件名为 index.html.[=,您可以尝试 ../index.html 10=]