开发者

URLRewriter.net with multiple querystring separated by /

I have been looking around the site a bit, but I didn't find any replies on how to do it the way I want.

What I want is an URL like this:

www.example.com/Projects/"querystring1 - text only"/"querystring2 - 4 digits only"/

to show the page with this URL:

www.example.com/Projects.aspx?Region=querystring1&Zip=querystring2

What I have been trying is the following:

<rewrite url="~/Leje-og-udlejning-arbejdskraft/(.+)/(.+)" to="~/Workers.aspx?Region=$1&amp;zip=$2"/>

But it just takes both of them as one querys开发者_JS百科ting and put them in the Region-querystring.


I'd need to see the rest of your rewrite rules to be sure, but if you have multiple rewrites (i.e. to handle situations where users only specify one of the two query strings) neglecting to add processing="stop" at the end will cause one rule to override the other.

For example, I use the following setup in my web.config file:

<rewriter>
    <rewrite url="~/(.+)/(.+)" to="~/Default.aspx?ref=$1&amp;page=$2" processing="stop"/>
    <rewrite url="~/(.+)" to="~/Default.aspx?ref=$1" processing="stop"/>
</rewriter>

This will first check to see if 2 query variables are present. If they are, it rewrites them appropriately and stops processing other rules. This is the biggie. Without processing="stop" at the end, I end up passing both as the ref query string. This might be the conflict you're running in to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜