当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net - Urlrewrite regex based on parameter

问题描述:

I would like to rewrite strings of this form:

"/folder/default.aspx?a=1&b=2&c=3" (example)

to

"/newfolder/?a=1&b=2&c=3"

if url contains "a=1"

Im using UrlRewritingNet

网友答案:

Try this:

<rewrites>
    <add name="SomeRuleNameHere" 
         virtualUrl="^~/folder/default\.aspx\?(.*&amp;)?a=1(&amp;.*)?$"
         destinationUrl="~/newfolder/?$1a=1$2"
         ignoreCase="true"
         rewriteUrlParameter="ExcludeFromClientQueryString" />
</rewrites>
分享给朋友:
您可能感兴趣的文章:
随机阅读: