IIS7 URL重写规则使友好的URL递归

时间:2013-05-28 11:54:39

标签: friendly-url url-rewrite-module

我有一个网站用asp和url重写了db提供者的规则。我工作正常,但我有一个烦人的问题,我无法正确解决。 重写的规则如下:

www.mydomain.com/default.asp --> www.mydomain.com/lang
www.mydomain.com/content.asp?id=1 --> www.mydomain.com/lang/category-title
www.mydomain.com/content.asp?id=1&ref=2 --> www.mydomain.com/lang/category-title/content-title

规则是:

    <rules>
    <clear />
    <rule name="dbp_Redirect" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{DB:{R:1}?{QUERY_STRING}}" pattern="(.+)" />
        </conditions>
        <action type="Redirect" url="{C:1}" appendQueryString="false" logRewrittenUrl="false" />
    </rule>
    <rule name="dbp_Reverse" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
            <add input="{DB_rewrite:{R:1}}" pattern="(.+)" />
        </conditions>
        <action type="Rewrite" url="{C:1}" logRewrittenUrl="false" />
    </rule>
</rules>
<outboundRules>
    <clear />
    <rule name="Outbounddbp_Reverse" preCondition="ResponseIsHtml1" enabled="true">
        <match filterByTags="A" pattern="^(.*/)(.*)" ignoreCase="true" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
            <add input="{DB_outbound:{R:2}}" matchType="Pattern" pattern="(.+)" ignoreCase="true" negate="false" />
        </conditions>
        <action type="Rewrite" value="{C:0}" />
    </rule>
    <preConditions>
        <preCondition name="ResponseIsHtml1">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
        </preCondition>
    </preConditions>
</outboundRules>

问题是当用户到达时

www.mydomain.com/lang/category-title/content-title

页面在此页面中重写的所有链接都是这样的:

www.mydomain.com/lang/category-title/content-title/*lang/category-title/content-title*

(如您所见,“lang/category-title/content-title”重复两次)

当然我在规则中遗漏了一些东西,但我看不出它是什么。

任何帮助都将不胜感激。

0 个答案:

没有答案