根据原始URL匹配得到要重写的URL地址
<UrlRewrite> <Rule Look="word-([0-9]+).aspx" Send="default.aspx?classid=0&id=$1" /> <Rule Look="word-([0-9]+)-([0-9]+).aspx" Send="default.aspx?classid=0|$1&id=$2" /></UrlRewrite>
string content = "default.aspx?classid=0&id=10"; System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"(?<=&id=)[\d]+"); System.Text.RegularExpressions.Match m = reg.Match(content); MessageBox.Show("word-"+m.Value+".aspx");
[解决办法]
把Look的([0-9]+)和Send的$对调,Send的&改为&,再Replace