且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET / IIS7 Url重写映射不起作用

更新时间:2023-02-25 13:30:03

这篇文章 http://www.iis.net/learn/extensions/ url-rewrite-module / using-rewrite-maps-in-url-rewrite-module 和下面的代码为我工作。

This article http://www.iis.net/learn/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module and code below worked for me.

<rewrite>
    <rules>
        <rule name="Redirect rule1 for RedirectURLs">
            <match url=".*" />
            <conditions>
                <add input="{RedirectURLs:{REQUEST_URI}}" pattern="(.+)" />
            </conditions>
            <action type="Redirect" url="{C:1}" appendQueryString="false" />
        </rule>
    </rules>
    <rewriteMaps>
        <rewriteMap name="RedirectURLs">
            <add key="/privacy.php" value="/privacy" />
        </rewriteMap>
    </rewriteMaps>
</rewrite>