4

我已经阅读了这些线程,但我仍然无法解决,我知道我的问题,但想知道是否可以为我指明正确的方向。

我设置了一个规则:

www.mydomain.com/productlist.asp?CategoryID=2

改写为

www.mydomain.com/homeware/cushions

.

            <rule name="cushions">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="productlist.asp?CategoryID=2" />
            </rule>

好的,现在我的问题是结果的分页,所以当用户进入下一页时的原始域如下所示:

www.mydomain.com/productlist.asp?CategoryID=2&Page=2

这就是我遇到问题的地方 - 我希望它变成:

www.mydomain.com/homeware/cushions?page=2

并且持续了多少页无法让它工作 - 我知道我需要使用查询字符串但真的很挣扎。求专业知识,谢谢帮助

4

2 回答 2

2

要捕获查询字符串,您需要为此使用条件,因为匹配 URL 不包含它。所以你可以用这样的规则来做到这一点:

<rule name="cushions" stopProcessing="true">
<match url="^homeware/cushions$" />
<conditions>
    <add input="{QUERY_STRING}" pattern="page=(\d+)" />
</conditions>
<action type="Rewrite" url="productlist.asp?CategoryID=2&amp;page={C:1}" appendQueryString="false" /> 

于 2011-06-27T16:02:24.407 回答
0

只需在操作中添加 appendQueryString="true" 将自动附加查询字符串。

<rewrite>
        <rules>
            <rule name="test">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="/test/test.cfm?category=5" appendQueryString="true" />
                <conditions>
                </conditions>
            </rule>
        </rules>
    </rewrite>

http://localhost:8081/homeware/cushions?page=2 您将在 URL 变量中收到值为 2 的页面。

于 2011-07-04T11:26:44.723 回答