【问题标题】:Resource interpreted as Image but transferred with MIME type text/html error资源解释为图像,但传输时带有 MIME 类型文本/html 错误
【发布时间】:2014-11-01 16:21:34
【问题描述】:

嘿,我一直在尝试将图像显示到我的页面背景,但它不工作,我不断收到错误

Resource interpreted as Image but transferred with MIME type text/html: 
"http://killerducky1.x10.mx/images/offline.png". killerducky1.x10.mx/:1

在 google chrome dev concole 上

从外观上看,它从第一行开始

<html>

我到处找了找,除了检查文件是否存在之外找不到修复方法

但我确实找到了一些说 .httaccess 与它有关的东西,所以我不确定它是因为我向它添加了离线/维护功能

.htt访问

# -FrontPage-
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /profile.php?username=$1
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
### Maintenance Mode ###    
RewriteCond %{REQUEST_URI} !^/(offline\.php|images/offline\.png)$
RewriteRule ^(.*)$ offline\.php [L]
### end of Maintenance Mode ###
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName killerducky1.x10.mx
AuthUserFile /home/killerdu/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/killerdu/public_html/_vti_pvt/service.grp

离线.php

<html>
<head>
    <title>We are offline !</title>  
  </head>
  <body>
<style>
body  {
    background-image: url('images/offline.png');
    background-color: #eee;
      background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center; 
    background-size: 1387px 729px;
}
</style>
</body>
</html>

【问题讨论】:

  • 似乎您的 htaccess 将 offline.png 重定向到 offline.php 这是一个文本/html 文件
  • 你的意思是说我的浏览器正在将offline.png 读取为文本文件?
  • 也许AddType image/png .png 不见了?
  • 不,仍然出现错误
  • 感谢您的帮助!但还是没有解决

标签: php .htaccess


【解决方案1】:

您的问题在这一行:

RewriteCond %{REQUEST_URI} !^/offline\.php$
RewriteRule ^(.*)$ offline\.php [L]

以上内容告诉任何不以/offline.php开头的东西都会被重定向到offline.php,其中包括图片。

您可以通过将其更改为来修复它:

RewriteCond %{REQUEST_URI} !^/(offline\.php|images/offline\.png)$
RewriteRule ^(.*)$ offline\.php [L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-18
    • 2011-12-24
    • 2014-05-20
    • 2012-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多