【问题标题】:Get 404 not found for webp images on the website获取网站上的 webp 图像未找到 404
【发布时间】:2019-09-08 11:14:14
【问题描述】:

我正在将网站的图片从 .jpg 替换为 .webp。我使用的方式是通过modernizr来检测浏览器是否可以接受webp,然后设置background-image。但是,webp 图像总是存在错误。有什么我没有设置的吗?或者我能做些什么来解决这个问题?

我已经尝试过更改背景颜色并且效果很好。

<script src="js/modernizr-custom.js"></script>
<style type="text/css">
.no-webp .bg {
    background-image: url('Image/img_Head02.jpg');
}
.webp .bg {
    background-image: url('Image/img_Head02.webp');
}

我希望 webp 类型的图像可以显示在网站上。 但是现在,出现错误:GET http://test.poct-bio.com/JobW/Image/img_Head02.webp 404 (Not Found)

【问题讨论】:

  • 试试manage.accuwebhosting.com/knowledgebase/2443/…。您可能需要将 webp 添加到 iis mime 类型。
  • @VDWWD 如果我已经在服务器上推送了网站,是否还需要将 webp 添加到 iis mime 类型?但是,我以前见过这种解决方案。但是对于win10,不知道在哪里可以找到设置。
  • 是的,我认为您需要这样做,但也在服务器上。该设置在 IIS 中,而不是 Windows 本身。

标签: c# asp.net webp


【解决方案1】:

你必须在 IIS 服务器中包含 mime 类型才能支持 webp 类型

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension="webp" mimeType="image/webp" />
        </staticContent>
    </system.webServer>
</configuration>

web.config

【讨论】:

  • 这个回复应该被标记为正确。非常感谢!
猜你喜欢
  • 2016-09-13
  • 2020-04-05
  • 2013-04-21
  • 1970-01-01
  • 2019-01-10
  • 2019-01-25
  • 2020-10-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多