使用查询字符串和问号 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
并持续多少页 只是无法让它工作 - 我知道我需要使用查询字符串,但真的很挣扎。求专业知识,感谢帮助
I have read the threads and I still can't work it out, my problem I know, but wondering if could point me in the right direction.
I have setup a rule:
www.mydomain.com/productlist.asp?CategoryID=2
rewritten to
www.mydomain.com/homeware/cushions
.
<rule name="cushions">
<match url="^homeware/cushions" />
<action type="Rewrite" url="productlist.asp?CategoryID=2" />
</rule>
ok, now my problem is with pagination of the results, so the original domain when the user goes onto the next page would look like:
www.mydomain.com/productlist.asp?CategoryID=2&Page=2
This is where I'm having problems - I want this to become:
www.mydomain.com/homeware/cushions?page=2
and ongoing for how many pages
just can't get it to work - I understand I need to use query string but really struggling. Asking for expertise, thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要捕获查询字符串,您需要使用条件,因为匹配 URL 不包含它。
所以你可以用如下规则来做到这一点:
To capture the Query String you need to use conditions for that since the match URL does not include it.
So you could do that with a rule like:
只需在操作中添加appendQueryString =“true”就会自动附加查询字符串。
http://localhost:8081/homeware/cushions?page=2
您将在 URL 变量中收到值为 2 的页面。
Just add appendQueryString="true" in action will automatically append query string.
http://localhost:8081/homeware/cushions?page=2
You will receive page in URL variable with value 2.