CSS文件是';当我将.html文件更改为.php时,没有正确链接


CSS file isn't properly linked when I change the .html file to a .php

这个问题是index.html文件独有的,正如我之前所说,当它是html时,CSS会在扩展名更改时停止工作。我检查了两个实例上的ref链接,当它是php时,CSS文件最终就是php文件本身。我假设它可能因为某种奇怪的原因无法访问css?我不确定只有当它是php时,它是如何翻译的。我对其他页面也做了同样的操作,效果很好。

如果这有什么意义的话,那么停止工作的部分原因是我正在使用的基金会。

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation</title>
<link rel="stylesheet" href="stylesheets/app.css" />
<link rel="stylesheet" href="stylesheets/main.css" />
<script src="bower_components/modernizr/modernizr.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.clearing.js"></script>
</head>

我还发现任何href链接都会停止工作。

我猜它是使用错误的MIME类型传递的。尝试通过如下设置标题来强制CSS MIME类型:

header("Content-type: text/css");

此外,请确保使用PHP时,应该使用服务器执行。即,以下URL是正确的:

http://domain/path/to/index.php
http://localhost/project/index.php

而不是:

file:///c:/wamp/www/project/index.php
file:///c:/myproject/index.php
file:///c:/xampp/htdocs/index.php