xbo*_*nez 4 css php 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>
Run Code Online (Sandbox Code Playgroud)
使用Chrome扩展程序,我在请求style.css时监控了正在发送的标头,这就是我得到的:

编辑
这是在共享godaddy主机上的LAMP服务器上.我的重写htaccess只包含以下重写规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
RewriteRule ^(.*)$ /index.php?$1 [L]
Run Code Online (Sandbox Code Playgroud)
这很可能是由css文件中的无效相对路径引起的.
例如,在html中,可以通过添加<img src="" />将类似的消息再现,将其解析为相对路径并解析为*current_page_url* - 提示"...但是使用MIME类型text/html传送"错误.