dongronge3732 2017-04-21 02:28
浏览 1059
已采纳

css未加载,因为其MIME类型“text / html”不是“text / css”

I am using netbeans 8.2 ide, Apache 2.4 with php7.

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”"

Things I have tried (restarting the erver between each):

  • "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

UPDATE

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);

this did not work, I then added into index.php the following:

header("X-Content-Type-Options: nosniff");

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

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

  • 写回答

1条回答 默认 最新

  • douxueke5653 2017-04-29 23:55
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?