.htaccess - 将 AddType 规则从 htaccess 转换为 web.config

标签 .htaccess web-config

我需要转换 .htaccess

AddType application/x-httpd-php .txt

到 web.config。你能帮我吗?我试过
    <configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="*.txt" 
         type="php " />
    </httpHandlers>
  </system.web>
</configuration>

但这对我不起作用。所以我需要在IIS上打开像php这样的txt文件。

最佳答案

这对我有用:

<configuration>
   <system.webServer>
      <staticContent>
         <mimeMap fileExtension=".syx" mimeType="application/octet-stream" />
         <mimeMap fileExtension=".tab" mimeType="text/plain" />
      </staticContent>
   </system.webServer>
</configuration>

来源:http://www.iis.net/configreference/system.webserver/staticcontent/mimemap

关于.htaccess - 将 AddType 规则从 htaccess 转换为 web.config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10817035/

相关文章:

.htaccess - 如何使用 .htaccess 将错误 404 重定向到主页?

html - 我不想将 HTML 文件名显示为主页,例如 stackoverflow.com,而不是 stackoverflow.com/home

当数据库中缺少项目时,PHP 或 htaccess 使动态 url 页面转到 404

msbuild - 如何在转换时将 configSource 转换为 web.config 中的内联元素

xpath - Web.Config 转换 xml 注释

c# - 允许任何用户在没有凭据的情况下访问 'signalr/hubs',使用 cors(服务器运行 windows 身份验证)

php - Apache 重写 - 本地主机中的干净 URL

apache - .htaccess RewriteCond %{REQUEST_FILENAME}

visual-studio - Visual Studio 无法删除服务引用

iis - 如何更改生成 IIS 中虚拟目录的 web.config 的位置?