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

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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题