开发者

Intelligencia URL ReWriter mapping with regex

I am using the Intelligencia URL rewriter in my asp.net web application. I use the web.config mappings

I'm trying to map the following url:

www.mydomain.com/product-deals/manufacturer-model_PRODUCTId.aspx

To:

www.mydomain.com/ProductInfo.aspx?productID=xxx

obviously in the above example, xxx is replaced from 开发者_开发问答the "productId" from the "friendly" url.

In my web.config, I've got so far:

<rewrite url="~/contract-deals/([\w-_]+)/_(.+).aspx" to="~/ProductInfo.aspx?productId=$1"/>

This isn't working however.

I need the correct regex to use for my requirements (regex really isn't my strong point!!)


One problem is that you have product-deals in your sample and contract-deals in the regex.

Next, your regex has an extra slash, and you don't escape the dot (though it can match a dot anyway). Also, $1 refers to the first capturing group, which in your case is "manufacturer-model".

This regex should get you what you want:

product-deals/[\w_-]+_(.+)\.aspx
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜