使用查询字符串和问号IIS 7重写IIS

问题描述

|| 我已经阅读了这些线程,但仍然无法解决,这是我所知道的问题,但是想知道是否可以为我指明正确的方向。 我设置了一个规则:
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
正在进行多少页 只是无法正常工作-我知道我需要使用查询字符串,但确实很费劲。寻求专业知识,谢谢您的帮助     

解决方法

要捕获查询字符串,您需要为此使用条件,因为匹配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\" /> 
       ,只需在操作中添加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的页面。