具有Mime映射的无扩展URL [英] Extensionless URLs with Mime Mapping

查看:111
本文介绍了具有Mime映射的无扩展URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在新主机上恢复旧网站。它最初使用MovebleType,因此所有模板文件都是无扩展名的HTML文件。我试图让IIS7为没有扩展名的文件提供所有文件请求 text / html 但没有太多运气。 IIS论坛上的帖子提出了一个重写规则,对我来说没有意义,似乎没有用。我还尝试了几个mimeMaps,所有这些都导致了HTTP错误。到目前为止,这是我的web.config:

I'm trying to resurrect an old site on a new host. It originally used MovebleType, so all of the template files are extensionless HTML files. I'm trying to get IIS7 to serve all requests to files without an extension as text/html but not having much luck. A post on the IIS forum suggested a rewrite rule, which to me doesn't make sense and doesn't seem to work. I've also tried several mimeMaps, all of which resulted in HTTP errors. This is my web.config so far:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
        <rewrite>
            <rules>
                <rule name="Extensionless" stopProcessing="true">
                    <match url="^[\w_/]+$" />
                    <action type="Rewrite" url="{R:0}.htm" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

.htaccess等价物更重要 - DefaultType php5-cgi

The .htaccess equivalent is more to the point - DefaultType php5-cgi

这应该可以在IIS7中实现吗?

This should be possible in IIS7 shouldn't it?

推荐答案

我实际上需要一个的MimeMap。

   <staticContent>
       <mimeMap fileExtension="." mimeType="text/html" />
   </staticContent>

这篇关于具有Mime映射的无扩展URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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