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
pedrofernandes
source
to share
5 answers
This will work
<rewrite url="~/Category/(.+).aspx(\?(.*))?" to="~/Pages/CategoryList.aspx?ID=$1&$3" />
0
Pavlo Neyman
source
to share
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
Stefan
source
to share
You added:
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
</httpModules>
to your web.config
file?
0
John Rasch
source
to share
you forgot to escape some special characters ("." and "?") and are not sure about "~":
<rewrite url=".*/Category/(.+)\.aspx\?Page=(.+)" to="/Pages/CategoryList.aspx?ID=$1&Page=$2" />
0
Kamarey
source
to share
Try the following:
<rewrite url="~/Category/(.+)\.aspx\?Page=(.+)"
to ="~/Pages/CategoryList.aspx?ID=$1&Page=$2" />
0
Rubens farias
source
to share