繁体   English   中英

IIS7 URL 重写规则以执行从 *.html 文件到 *.php 文件的 301 重定向

[英]IIS7 URL Rewrite rule to perform a 301 redirect from *.html files to *.php files

我想使用 IIS7 的 URL 重写模块根据特定模式创建 301 重定向。

我有一个 web 站点,其中仅包含 .HTML 文件。 我正在将该站点转换为 .PHP 文件,但保留所有相同的文件名。 例如,以下网址...

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

会变成...

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

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

谢谢。

这里是 go:

<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>

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM