文件夹中的PHP文件不会呈现默认的CSS文件。
我有一个"document-head.php"文件,其中包含:
<link type="text/css" rel="stylesheet" href="assets/css/main.css"/>
在每个文件中,我都包含了这个"document-head.php";
例如,我的目录是:
index.php
|__ assets
|__ css
|__ main.css
|__ includes
|__ document-head.php
|__ components
|__ secondary.php
|__ partials
在"components/secondary.php"中包含
<?php include('../_includes/document_head.php'); ?>
在"index.php"中包含:
<?php include('_includes/document_head.php'); ?>
如何确保包含此"document_head.php"的文件夹中的文件始终呈现CSS/JS文件?
编辑:我不能使用绝对URL的原因是,其中一位开发人员配置了一个脚本,允许我将应用程序上传到FTP,在那里我可以命名一个新文件夹。例如,如果我所有的文件都在"secret app"中,在终端中,我可以将我的应用程序发布到FTP,并使用新文件夹"test app",它将创建"mydomain.com/test app/secret app"。(这是一个贫民区系统,但对我的特定需求很有用。)
尝试更改为绝对href url,如:
<link type="text/css" rel="stylesheet" href="/yourApp/assets/css/main.css"/>
如果您使用的是一个框架,那么有几种方法可以获得base_url。
如果此样式表在document_head.php 中
<link type="text/css" rel="stylesheet" href="assets/css/main.css"/>
然后试试这个:
<link type="text/css" rel="stylesheet" href="../assets/css/main.css"/>
对不起我的语法:D