views:

231

answers:

1

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

A: 

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
Kobi
worked great, thanks
alex