2011-05-26 54 views
3

我已经阅读了主题,但仍然无法解决问题,我知道我的问题,但是想知道是否可以指引我朝着正确的方向发展。使用查询字符串和问号IIS进行IIS重写IIS 7

我已经建立了规则:

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> 

OK,现在我的问题是结果的分页,所以看起来,当用户进入到下一个页面的原始域,如:

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

这是我遇到的问题 - 我想这成为:

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

,并持续了多少页 只是无法得到它的工作 - 我知道我需要使用的查询字符串,但真正地奋斗。请求专业知识,感谢您的任何帮助

回答

1

要捕获查询字符串,您需要使用条件,因为匹配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" /> 

0

只需添加appendQueryString行动会自动追加查询字符串=“真”。

<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