views:

56

answers:

2
+1  Q: 

urlrewriter.net

Hello all!

I have a question concerning urlrewiter. I want to rewrite the following url like this:

<rewrite url="~/sportswear/browse-by-category/(\d+)/(.+)/(\d+)" to="~/Browse.aspx?cid=9&amp;type=category&amp;mid=$1&amp;p=$2" />

This does work but my get variable p cannot be read. However when i write 'shoes' which is the categoryname instead of (.+) it works perfectly. Does anyone know what seems to be the problem?

Thanks for your time.

Kind regards, Mark

A: 

Oooow sorry guys, i figured it out already, i had to replace $2 with $3 since that was the regex array number. Thanks anyways! :)

Mark
+1  A: 

Actually, you should start learning to make your groups non capture:

<rewrite url="~/sportswear/browse-by-category/(\d+)/(?:.+)/(\d+)" to="~/Browse.aspx?cid=9&amp;type=category&amp;mid=$1&amp;p=$2" />

Basically, just use (?:) instead of () if you don't want to capture it. Additionally, there was no need to group that .+, no?

<rewrite url="~/sportswear/browse-by-category/(\d+)/.+/(\d+)" to="~/Browse.aspx?cid=9&amp;type=category&amp;mid=$1&amp;p=$2" />
Avindra Goolcharan