如果指定的URL没有.PNG扩展名,Internet Explorer将显示.PNG图像? [英] How to make Internet Explorer display .PNG image if its URL is specified without .PNG extension?

查看:109
本文介绍了如果指定的URL没有.PNG扩展名,Internet Explorer将显示.PNG图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我希望 IE 可以显示png图片,由URL
表示 http://update1.osmp.ru/logos/7642909813539583507

 < HTML> 
< head>
< title>未能在网址< / title>中显示不带.png扩展名的png图片
< / head>
< body>
< img src =http://update1.osmp.ru/logos/7642909813539583507>
< / body>
< / html>

不起作用,因为 http://update1.osmp.ru/logos/7642909813539583507 未被 IE 解析为PNG文件。是否有任何解决方法,插件,无论在 IE中使用 img 标签显示这样的url资源?

解决方案

URL中没有文件扩展名。只是看起来像文件扩展名的东西,可能会映射到文件系统上的文件。



这是确定HTTP资源将如何工作的内容类型被处理,如果你检查那一个......


  [david] [david @ raston]% lynx -dump -headhttp://update1.osmp.ru/logos/7642909813539583507
HTTP / 1.1 200 OK
日期:2015年10月7日(星期三)09:24:16 GMT
Content-Type:text / plain


...你会看到服务器声称它是纯文本文件而不是PNG图像( image / png )。



您需要修复服务器,以便发送正确的内容类型。



您如何做到这一点将取决于您用于生成映像的服务器和任何服务器端软件。 / p>

例如,如果您正在提供没有文件扩展名的静态文件(服务器通常在文件上使用文件扩展名系统来确定静态文件的内容类型),并且您正在使用Apache HTTPD,那么您可以使用 ForceType 指令



例如在您的服务器配置中:

 < Location / logos /> 
ForceType图片/ png
< /位置>


For example, I wish IE could display png image, represented by URL "http://update1.osmp.ru/logos/7642909813539583507":

<html>
    <head>
        <title>Failed to display png image that comes without .png extension in URL</title>
    </head>
    <body>
        <img src="http://update1.osmp.ru/logos/7642909813539583507">
    </body>
</html>

It doesn't work because http://update1.osmp.ru/logos/7642909813539583507 is not resolved as PNG file by IE. Is there any workaround, plug-in, whatever to display such a url resource in IE using img tag?

解决方案

There's no such thing as a file extension in a URL. Just things that look like file extensions and might happen to map on to a file with one on the file system.

It is the content type that determines how an HTTP resource will be handled, and if you examine that one…

[ david ][ david@raston ] %  lynx -dump -head "http://update1.osmp.ru/logos/7642909813539583507"
HTTP/1.1 200 OK
Date: Wed, 07 Oct 2015 09:24:16 GMT
Content-Type: text/plain

… you'll see that the server claims it is a plain text file and not a PNG image (image/png).

You need to fix the server so it sends the correct content type.

How you do this will depend on the server and any server side software you are using to generate the image.

For instance, if you are serving up a static file which doesn't have a file extension (servers normally use the file extension on the file system to determine the content type for static files) and you are using Apache HTTPD, then you could use the ForceType directive.

e.g. in your server configuration:

<Location /logos/>
    ForceType image/png
</Location>

这篇关于如果指定的URL没有.PNG扩展名,Internet Explorer将显示.PNG图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆