IIS7 URL 重写规则以执行从 *.html 文件到 *.php 文件的 301 重定向 [英] IIS7 URL Rewrite rule to perform a 301 redirect from *.html files to *.php files

查看:19
本文介绍了IIS7 URL 重写规则以执行从 *.html 文件到 *.php 文件的 301 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to use the URL Rewrite module of IIS7 to create 301 redirects based on a specific pattern.

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

I have a web site that consists of only .HTML files. I am converting the site to .PHP files, but keeping all of the same filenames. For example, the following urls...

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

会变成……

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

谁能就如何创建此规则提出建议?

Can anyone advise on how to create this rule?

谢谢.

推荐答案

给你:

<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 上测试 -- 工作正常.

Tested on IIS 7.5 with URL Rewrite module v2.0 -- works fine.

这篇关于IIS7 URL 重写规则以执行从 *.html 文件到 *.php 文件的 301 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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