问题描述
我正在使用netbeans 8.2 ide,Apache 2.4和php7.
I am using netbeans 8.2 ide, Apache 2.4 with php7.
我已经下载了Bootstrap,并尝试将其链接到index.php中,但距离我还不远.
I have downloaded Bootstrap and am trying to link it into index.php i haven't far. When I test the example page on localhost I the error "css was not loaded because its MIME type, "text/html", is not "text/css""
我尝试过的事情(重新启动每个设备之间的erver):
Things I have tried (restarting the erver between each):
- 我的httpd.conf文件和vhost中的
- "AddType text/css .css"
- 确保php strict_mode关闭(在帖子中看到)
- 检查了mime.types(在那里)text/css-css 的类型.
-
在php.ini文件中将default_mimetype ="text/html"更改为default_mimetype ="
- "AddType text/css .css" in my httpd.conf file and also in vhost
- ensured php strict_mode is off (saw it in a post)
- checked mime.types for the type (which is there) text/css - css
changed default_mimetype = "text/html" to default_mimetype = "" in the php.ini file
更新
我做了一些研究,结果发现PHP会出于任何原因将.css解析为html并更改其mime类型(不完全确定所有方式如何工作,但似乎是这样).因此,我将.css文件重命名为.php文件,并将代码添加到每个.css文件中
I did a bit more research turns out PHP will parse .css as html for whatever reason and change its mime type ( not exactly sure how that all works but seems to be the case). So I renamed the .css files as .php files and added the code into each .css file
header('Content-type: text/css', true);
这不起作用,然后我将以下内容添加到index.php中:
this did not work, I then added into index.php the following:
header("X-Content-Type-Options: nosniff");
由于完全没有mime类型,这只是阻止了样式表的加载!甚至与Content-type结合使用.
this just prevented the loading of the stylesheets because of lack of mime type at all! even in conjunction with Content-type.
我还包含了对服务器的请求和响应标头的捕获在此处输入图像描述
also i have included a capture of the request and response headers to the serverenter image description here
非常感谢您的帮助,这非常令人沮丧,我正尝试着进行一些基本的Web设计,但我什至无法超越随附的Netbeans模板.我觉得这与PHP7或Apache 2.4的配置有关,但我不知道下一步是什么
thank you very much for any help this is very frustrating I'm trying to get into some basic web design but I can't even make it past the included Netbeans template. I have a feeling it's something to do with the configuration of PHP7 or Apache 2.4 but i have no idea were to go next
推荐答案
我最终卸载了自我配置的Apache服务器,并安装了预配置的WAMP Apache服务器,该服务器解决了我的问题,因此在某处不确定某个配置问题,但不确定现在工作很好.
I ended up uninstalling my self configured Apache server and installed the pre-configured WAMP Apache server which solved my problem so there a configuration problem somewhere not sure what but everything is working great now.
这篇关于未加载css,因为其MIME类型"text/html"不是"text/css"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!