dongronge3732 2017-04-20 18:28
浏览 1086
已采纳

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 15: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 为什么树莓派5b显示禁止连接
  • ¥20 流量太费!寻找便宜的app音视频SDK或平替方案。
  • ¥15 kubeasz部署遇到问题
  • ¥15 GUIDE to App Designer Migration Tool for MATLAB
  • ¥50 第三代非支配排序遗传算法(NSGA-Ⅲ)和多目标粒子群优化算法(MOPSO)的实现
  • ¥20 plant simulation与python com接口实时数据交互
  • ¥15 有关汽车的MC9S12XS128单片机实验
  • ¥15 求c语言动态链表相关课程有偿,或能将这块知识点讲明白
  • ¥15 FLKT界面刷新异常
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部