这是我的目录结构:
-根
--docs
--- doc1.php
--includes
---的header.php
--- footer.php
--- css.css
--index.php
在我的标题中,我链接到我的CSS文件,如下所示:
<link href="includes/styling.css" type="text/css" rel="stylesheet" />
Run Code Online (Sandbox Code Playgroud)
这适用于index.php,因为它是正确的路径(root/includes/css.css).
但是对于doc1.php来说,这不是正确的道路.(根/文档/包括/ css.css).
如何在保留一个包含该行代码的header.php文件的同时修复此问题?有没有办法强制路径在根目录中启动?
使用绝对路径而不是相对路径.
<link rel="stylesheet" type="text/css" href="/root/includes/css.css" />
Run Code Online (Sandbox Code Playgroud)