Mark
Mark

Reputation: 11

urlrewriter.net

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

Upvotes: 1

Views: 163

Answers (2)

Avindra Goolcharan
Avindra Goolcharan

Reputation: 4261

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" />

Upvotes: 1

Mark
Mark

Reputation: 11

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

Upvotes: 0

Related Questions