为什么 URLRewriter.NET 无法获取查询字符串值?
我刚刚开始在我的博客中使用 URLRewriter.net,但在获取查询字符串值时遇到问题。我有一个规则设置,例如:
<rewrite url="~/blog.aspx(\?.+)?$"
to="~/hiddenFolder/blog.aspx?mode=default&$2"/>
但是当我尝试访问 /blog.aspx?page=1 时,页面参数未传递。其他参数效果很好,重写规则不存在冲突。
I just started using URLRewriter.net with my blog and I have a problem with getting the query string values. I have a rule setting like:
<rewrite url="~/blog.aspx(\?.+)?$"
to="~/hiddenFolder/blog.aspx?mode=default&$2"/>
But when I try to access /blog.aspx?page=1 the page parameter is not passed. Other parameters work great and there are no conflicts in rewriting rules.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于 $2 超出了范围,因为您的正则表达式中只有一组。尝试 1 美元。
编辑
此外,查询字符串可能附加了另一个“?”所以你需要将其移出括号。
您还需要一个额外的组来使规则与我们的规则匹配(不带“?”)。注意:我们现在的结果又回到了 2 美元:)
I think the problem is that $2 is out of range as you only have one group in your RegEx. Try $1.
EDIT
In addition, it could be that the query string is being appended with another '?' so you need to move that out of the brackets.
You'll also need an extra group to make the rule match with our without the '?'. Note: we're back to $2 in the result now :)