URL Rewriter.NET and multiple requests
I emphasize trying to create a rewriter.net url rule for my website.
I have a link
http://localhost/Pages/CategoryList.aspx?ID=2&Page=1
And I want to replace it with
http://localhost/Category/2.aspx?Page=1
I tried the following:
<rewrite url="~/Category/(.+).aspx?Page=(.+)" to="~/Pages/CategoryList.aspx?ID=$1&Page=$2" />
But it didn't work.
Can anyone help me?
+2
source to share
5 answers
Try the following:
<rewrite url="~/Category/([0-9]+)\.aspx\?Page=([0-9]+)" to="~/Pages/CategoryList.aspx?ID=$1&Page=$2" />
Or better (shorter):
<rewrite url="~/Category/(d+)\.aspx\?Page=(d+)" to="~/Pages/CategoryList.aspx?ID=$1&Page=$2" />
I think that "." you are using too greedy and too much matches.
+2
source to share