c# - UrlRewriter.net exclusive regex rules -
i trying add rewrite rules using urlrewriter.net asp.net web app. problem regex newbie, , provided examples pretty elementary.
my question is: how differentiate urls contain query parameters?
i.e., if add rule:
<rewrite url="~/([.+])" to="~/$1.aspx" /> it rewrite www.example.com/products www.example.com/products.aspx, rewrite www.example.com/products?id=1 www.example.com/products?id=1.aspx.
problem happens when using login control, since creates url similar www.example.com/login?returnurl=/members, , not sure how rewrite it.
what is:
- to rewrite
www.ex.com/testwww.ex.com/test.aspx, and - to rewrite
www.ex.com/test?page=dummywww.ex.com/test.aspx?page=dummy.aspx
thanks lot!
[edit] , btw still haven't figured how turn on console debugging urlrewriter. have added "register logger" section config file, vs output windows shows nothing. helpful, also.
use following regex match:
"~/([^\?]+)(.*)?"
this way match until question mark - 1 or more chars aren't question mark.
then $1 holds path part, , $2 "?" until end of url.
notice question mark after second grouping parentheses - means don't require part, www.ex.com/test work.
Comments
Post a Comment