【问题标题】:IIS 7.0 rewrite module for file name用于文件名的 IIS 7.0 重写模块
【发布时间】:2012-08-15 16:01:23
【问题描述】:

我有一个网站,其中包含许多指向 *.index.html 页面的链接,这些页面不再存在,所有默认文档现在都已更改为 index.htm,我正在尝试设置 URL 重定向/重写到新页面但没有运气,这里有一个例子:

http://example.com/somedirectory/maybeanotherdirectory/index.html

我需要将该请求重定向到:

http://example.com/somedirectory/maybeanotherdirectory/index.htm

我在 web.config 中添加了不同的规则,但目前我只能重定向到:

http://example.com/index.htm

如何在仅将 index.html 更改为 index.htm 的同时维持确切路径?

【问题讨论】:

  • 如果我有一个 IIS 服务器启动并运行,我会尝试再次解决它并帮助您,但我记得尝试编写这些规则非常令人困惑......当然,我以前也只通过 GUI 使用过它,所以也许我不会有帮助

标签: regex iis mod-rewrite iis-7 url-rewriting


【解决方案1】:

这么老的问题,我偶然发现它纯粹是偶然的。如果有人在寻找答案时遇到它,您可以安装 IIS URL ReWrite 模块,并将以下内容添加到您的 web.config:

    <rewrite>
        <rules>
            <rule name="Html to htm">
                <match url="(.*)\.html" />
                <action type="Rewrite" url="{R:1}.htm" />
            </rule>
        </rules>
    </rewrite>

干杯!

【讨论】:

    猜你喜欢
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    • 2011-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多