还是不行,
假如我输入http://abc.cn/news/  匹配结果是:http://abc.cn/default.aspx?param=news
或者http://abc.cn/ 匹配结果是http://default.aspx?param=abc.cn

解决方案 »

  1.   

    @"(?<=[^\.cn]/)([0-9a-zA-Z|]*)/$"
    我这样去写,
    当我http://abc.cn/aboutUs/notice/的时候访问的http://abc.cn/aboutUs/default.aspx,应该访问的是notice文件夹下的default.aspx文件才对,其他访问都正常
      

  2.   


            pattern = string.Format(@"/(.[0-9a-zA-Z]*)/$");
            if (Regex.IsMatch(requestPath, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
            {
                string file = requestPath.Substring(0, requestPath.Length - 1) + ".aspx"; ;
                file = Server.MapPath("~" + file);          
                if (System.IO.File.Exists(file))
                    file = "/$1.aspx";
                else
                    file = "/default.aspx?param=$1";
                   // 这里的问题, /default.aspx?param=$1  代表的是根目录,需要把路径加到这里,用这则提取一下路径加进来就行 了
                string newUrl = Regex.Replace(requestPath, pattern, file, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                Context.RewritePath(newUrl);
            }
      

  3.   

    http://www.itzlk.com/jskernel/456.jhtml