Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Apache2:当文件位于另一个文件夹中时不加载CSS_Html_Css_Apache2 - Fatal编程技术网

Html Apache2:当文件位于另一个文件夹中时不加载CSS

Html Apache2:当文件位于另一个文件夹中时不加载CSS,html,css,apache2,Html,Css,Apache2,问题是我的CSS没有加载。 我有一个文件夹/var/www/example,其中有index.php 还有另一个文件夹资产,其中有文件夹/css 在my index.php中,我将css链接如下: <link type="text/css" href="/assets/css/style.css" rel="stylesheet"> 但是当我用index.php将style.css放入/var/www/example时,我将代码更改为 href=“style.css它可以工作

问题是我的CSS没有加载。

我有一个文件夹/var/www/example,其中有index.php 还有另一个文件夹资产,其中有文件夹/css

在my index.php中,我将css链接如下:

<link type="text/css" href="/assets/css/style.css" rel="stylesheet">

但是当我用index.php将style.css放入/var/www/example时,我将代码更改为
href=“style.css
它可以工作


我正在使用Apache2根目录是
示例
,因此您必须将
/example
放在
资产
之前。链接应该如下面的示例所示,另一个想法是删除
/code>资产
之前的
/code>,因为它不是
根目录
(即它是目录)php的
index.php
文件


您使用的是CSS文件的根相对路径,而
/example
可能是根文件夹,因此您需要
/example/assets/CSS/style.CSS
或者您可以尝试
href=“assets/CSS/style.CSS”“
如果要将CSS文件链接到索引位置page@MonkeyZeus我试过了,我仍然有同样的问题你的
index.php
文件的URL是什么?是
http://localhost/example/index.php
?还有,CSS文件的完整路径是什么?@MonkeyZeus当我进入时,我没有找到页面,但当我进入localhost/i有我的索引。p在注释前,
/example
在访问
index.php