我有一个具有这种结构的网站:
- /根目录/
- 产品/
- products.php
- products.php
- 产品/
CSS/
- 样式.css
index.php
这就是问题所在:index.php 将 style.css 链接到相对路径,如“../CSS/style.css”
products.php 使用 include "../index.php"包含 index.php
但是没有包含 css,因为现在 index.php 与 products.php 在同一个文件夹中,所以相对路径不起作用!
有没有绝对路径的解决方案,因为我不想让人们知道我元素的结构
如果没有,你能给我绝对路径吗?或者我能以某种方式对用户隐藏绝对路径
预先感谢您的宝贵时间
最佳答案
尝试使用这种语法:
<link rel="stylesheet" type="text/css" href="/CSS/style.css">
关于PHP包含不同的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42396818/