Chrome将CSS样式表解释为图像

时间:2012-06-25 02:12:07

标签: php css codeigniter http-headers

在我的CodeIgniter网站中,当在Chrome中查看时,控制台会显示警告

style.css interpreted as IMAGE but transferred with MIME type text/css

页面按照我的预期呈现,但是当我右键单击并检查任何元素时,它的“计算样式”显示为空白,使调试变得困难。

这就是我提供CSS文件的方式

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><?php echo $title; ?></title>        
        <link rel="icon" type="image/png" href="<?= base_url('assets/images/favicon.png'); ?>" />       
        <link rel="stylesheet" type="text/css" media="all" href="<?= base_url('assets/css/style.css');?>" />
        <link href='http://fonts.googleapis.com/css?family=Oswald:400,700|Open+Sans+Condensed:300,300italic,700' rel='stylesheet' type='text/css'>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>        
    </head>

使用Chrome扩展程序,我在请求style.css时监控了正在发送的标头,这就是我得到的:

enter image description here

修改

这是在共享godaddy主机上的LAMP服务器上。我的重写htaccess只包含以下重写规则:

RewriteEngine On
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteBase /
RewriteRule ^(.*)$ /index.php?$1 [L]

1 个答案:

答案 0 :(得分:5)

这很可能是由css文件中的无效相对路径引起的。

例如 in html 可以通过添加<img src="" />来复制类似的消息,{{1}}将被解析为相对路径并解析为* current_page_url * - 提示&#34; .. .but转移MIME类型text / html&#34;错误。