求一正则匹配表达式 还是不行,假如我输入http://abc.cn/news/ 匹配结果是:http://abc.cn/default.aspx?param=news或者http://abc.cn/ 匹配结果是http://default.aspx?param=abc.cn 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 @"(?<=[^\.cn]/)([0-9a-zA-Z|]*)/$"我这样去写,当我http://abc.cn/aboutUs/notice/的时候访问的http://abc.cn/aboutUs/default.aspx,应该访问的是notice文件夹下的default.aspx文件才对,其他访问都正常 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); } http://www.itzlk.com/jskernel/456.jhtml 用js和html5做了个斗地主 EXTJS 之中如何使用百度的文本编辑器 ??或者如何修改EXTJS自己的文本编辑器? 再或者如何自己照着百度写一个控件? JS焦点图论坛代码怎么修改 MzTreeView的问题,有使用过的进...... ie6下 ajax的回调函数问题 这个免费短信的页面数据提交到哪里了? fullscreen 求救,急!!!请各位指教! 如何在网页中起动别的应用软件? Bootstrap-Table实现前端的Table 用URL接收JSP的JSON数据,显示匹配不到 菜鸟求救,HTML插入JS问题,按钮怎么没有响应 js checkbox 勾选
我这样去写,
当我http://abc.cn/aboutUs/notice/的时候访问的http://abc.cn/aboutUs/default.aspx,应该访问的是notice文件夹下的default.aspx文件才对,其他访问都正常
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);
}