首页 > 解决方案 > 具有特殊文件名的 IIS?

问题描述

我用“wayback_machine_downloader”下载了一些网站。有些文件的名称如super.html!q=4343. 但 IIS 并未将其检测为 HTML 文件,Windows 检测到文件扩展名为.html!q=4343.

我想要这样的东西:当人们去的时候,http://www.example.com/super.html!q=4343我想把这个文件显示为一个普通的 HTML。这在代码中只是一个纯 HTML。

我知道要更改扩展名,但其他 HTML 文件链接到这个/super.html!q=4343

还有一些具有不同编号和内容的文件。(喜欢/super.html!q=6556/super.html!d=5545

我不擅长写英语问题,但这是我最好的。对此感到抱歉。

有没有办法解决?谢谢!

标签: htmliishandler

解决方案


通常,您需要在网站的 web.config 中添加 mime 地图。例如,要使 URLhttp://www.example.com/super.html!q=4343起作用,您可以执行以下操作:

<configuration>
  <system.webServer>
      <staticContent>
         <mimeMap fileExtension=".html!q=4343" mimeType="text/html" />
      </staticContent>  
  </system.webServer>
</configuration>

以上仅适用于特定扩展。要使用所有扩展程序,请使用下面的代码段。这将适用于所有扩展。

<configuration>
  <system.webServer>
      <staticContent>
         <mimeMap fileExtension="*" mimeType="text/html" />
      </staticContent>  
  </system.webServer>
</configuration>

推荐阅读