【问题标题】:IIS7 URL Rewrite rule to perform a 301 redirect from *.html files to *.php filesIIS7 URL 重写规则执行从 *.html 文件到 *.php 文件的 301 重定向
【发布时间】:2011-10-26 19:46:07
【问题描述】:

我想使用 IIS7 的 URL Rewrite 模块来创建基于特定模式的 301 重定向。

我有一个只包含 .HTML 文件的网站。我正在将该站点转换为 .PHP 文件,但保留所有相同的文件名。比如下面的urls...

/index.html
/contact/contact.html
/membership/member.html

会变成……

/index.php
/contact/contact.php
/membership/member.php

谁能建议如何创建此规则?

谢谢。

【问题讨论】:

    标签: iis iis-7 url-rewriting


    【解决方案1】:

    给你:

    <system.webServer>
        <rewrite>
            <rules>
                <rule name="html2php" stopProcessing="true">
                    <match url="^(.+)\.html$" />
                    <action type="Redirect" url="{R:1}.php" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
    

    在带有 URL 重写模块 v2.0 的 IIS 7.5 上测试——工作正常。

    【讨论】:

    • 仍在努力完成网站。它会在几天内运行,然后我会让 URL 重写工作。我会告诉你;我保证。
    猜你喜欢
    • 2012-01-09
    • 2010-12-07
    • 1970-01-01
    • 2014-07-19
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    相关资源
    最近更新 更多