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

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 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 maven环境配置后无法运行mvn -v
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动