我目前正在处理管理员后端,现在想将一些页面移动到不同的文件夹中(因此我没有将所有脚本放在一个文件夹中)。 结构看起来像这样:
/
/theme/assets/...
/templates/head.php
/templates/foot.php
/top/index.php
/index.php
在head.php中有一些样式表添加如下
<link href="theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
这适用于根文件夹中的文件(例如index.php),但是当我在/top/index.php中使用相同的head.php时它不起作用,因为路径错误。 是否有可能在将脚本放在不同文件夹中时正确包含样式表等?
格尔茨,
答案 0 :(得分:2)
只需在/
属性的开头指定根标识符(href
):
<link href="/theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
答案 1 :(得分:0)
试试这个,
<link href="../theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
在/top/index.php
OR
<link href="<?php echo $_SERVER['DOCUMENT_ROOT'] ?>/theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
此代码可用于任何页面。 $_SERVER['DOCUMENT_ROOT']
指向根。
答案 2 :(得分:0)
使用&#39; ../'引用上面的文件夹并继续前进。 例如
<link href="../theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">