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

查看:720
本文介绍了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 Rewrite module 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天全站免登陆