Why URLRewriter.NET doesn't get querystring values?

江枫思渺然 提交于 2019-12-25 12:19:28

问题


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&amp;$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.


回答1:


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 :)

<rewrite url="~/blog.aspx(\?(.+)?)?$"
    to="~/hiddenFolder/blog.aspx?mode=default&amp;$2"/>


来源:https://stackoverflow.com/questions/3344097/why-urlrewriter-net-doesnt-get-querystring-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!