IIS: How to serve a file without extension?

做~自己de王妃 提交于 2019-11-27 18:41:26
Peter Hahndorf

Assuming (path) is a physical directory on your machine, create a new web.config file in that directory with the following content:

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

You are telling IIS that for this directory only, any file without an otherwise defined extension (in MIME types) should be considered an xml file. Other file types in the same path should still work.

It can be done in IIS 6 as well / without using web.config, but instead using the management GUI to add a MIME type for extension . here:

For instance, to serve a .well-known/acme-challenge token, create a virtual directory called .well-known, and have it take its contents from a physical directory (that cannot have names with leading dots in windows). Then add a text/plain MIME type for the extension . in this directory, and you can manually acquire new letsencrypt certificates for a domain that is currently served by an old IIS.

Changing the configurations by hand can be risky at times. IIS provides a methodology to update the MIME-types through IIS manager also as below. The snapshots are for IIS v10 installed on a windows 10 box:

  1. Go to MIME Types feature of the virtual directory of your website:

  1. Set up the mime type to support all files without extension :

These steps effectively saves the changes to web.config of your website or virtual directory (under your website) as suggested by @PeterHahndorf in his post.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!