Hi guys,
could you help me to create a simple url rewriting for this.
ex: http://mysite.com/product/23/default.aspx
ex: http://mysite.com/product/23/category/23/default.aspx
ex: http://mysite.com/product/23/category/23/manufacture/2/default.aspx
Basically I want a regex that can match above url, so i can rewrite the url to :
http://mysite.com/default.aspx?product=23
http://mysite.com/default.aspx?product=23&category=23
http://mysite.com/default.aspx?product=23&category=23&manufacture=2
I want the product, category, manufacture can be any words (so it is not specified to these words)
Let say I have the following url:
http://mysite.com/myname/robert/default.aspx
It should then return to http://mysite.com/default.aspx?myname=robert
The problem is this, i create a regex :/([\w-]*)/([\w-]*)/([\w-]*).aspx
i want that above regex only accept the following:
/anyword/anyword/anyword.aspx
but if I type in /anyword/anyword.html ==>this one still matches
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am doing in asp.net, and below are the regex rules that i use to match the urls
<rule>
<url>/([\w-]*).aspx</url>
<rewrite>/Default.aspx?PageName=$1</rewrite>
</rule>
<rule>
<url>/([\w-]*)/([\w-]*)/([\w-]*).aspx</url>
<rewrite>/Default.aspx?PageName=$3&$1=$2</rewrite>
</rule>
<rule>
<url>/([\w-]*)/([\w-]*)/([\w-]*)/([\w-]*)/([\w-]*).aspx</url>
<rewrite>/Default.aspx?PageName=$5&$1=$2&$3=$4</rewrite>
</rule>
I could think above solution is to bad.
Any advise for me?