来自 HTML 的链接将转到根目录而不是同一文件夹? (本地主机)

Links from HTML are going to root instead of the same folder? (LocalHost)

// THIS WORKS ('contact' is the folder we're in)
<link rel="stylesheet" type="text/css" href="../contact/local.css">

// THESE DO NOT WORK (they point to a 'local.css' in the root directory)
<link rel="stylesheet" type="text/css" href="./local.css">
<link rel="stylesheet" type="text/css" href="local.css">

这只是 'localhost' 上的一个问题。它在我使用的网络服务器上运行良好,但如果我可以使用'./'进行测试,那就太好了。

我正在使用 PhpstormPHP 内置 Web 服务器.

这是 known issue 用于 PHP 内置网络服务器。 目前,即使它是一个目录,网络服务器处理路径时也没有尾随 / 作为文件。

要解决此问题,请确保您的 URL 中有尾部正斜杠。

例如而不是 http://localhost/folder, use http://localhost/folder/