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