Resource interpreted as stylesheet but transferred with MIME type text/html

This is my html:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv = "Content-Language" content = "en"/>
        <meta http-equiv = "Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="/xxx/app/www/style.css">

Now when I load the page, Safari's inspector gives me:

Resource interpreted as stylesheet but transferred with MIME type text/html

I'm working on localhost with MAMP. I'm not sure what to modify to get this to work. I read that this might be a server problem of some kind.

How do I solve it?


Create an .htaccess file into your root folder (or update the existing one) with this line inside

AddType text/css .css 

this will tell apache to send the right content-type header for .css file


There is possibility that not just css resources were interpreted wrongly. It maybe a problem of your webserver configuration.

The best way to check is to go to Chrome -> Network tab and check responses section for each request. Also you can run $ curl -I http://path_to_file_or_page with terminal and have a look at response, you should see it in following format, eg Content-Type: image/jpeg


So, if it will occur that webserver (apache) does it for all filesthen you can try to solve the problem in following way:

Check your /etc/apache2/apache2.conf If there are any SetHandler application/x-httpd-php line, try to comment it and then reload your apache by $ sudo system apache2 reload

Let us know if the problem is still there.

链接地址: http://www.djcxy.com/p/47014.html

上一篇: 样式表使用node.js与错误的MIME类型一起发送,我该如何解决这个问题?

下一篇: 资源被解释为样式表,但是以MIME类型text / html传输