惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
D
Docker
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
罗磊的独立博客
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
博客园 - 司徒正美
T
Tailwind CSS Blog
C
Check Point Blog
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Proofpoint News Feed
L
LangChain Blog
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
有赞技术团队
有赞技术团队
腾讯CDC
Last Week in AI
Last Week in AI
Jina AI
Jina AI
博客园 - Franky
量子位

博客园 - Hover

找出隐藏的字符 - Hover - 博客园 GZIP压缩导致无法输出缓冲区内容。 asp.net 开发WAP MFC 试图执行系统不支持的操作 VC2005 无法打开RC文件.提示Opened in another editor DIALOG Undeclared identifier 找回VISUAL STUDIO 2005丢失的模板 用OD和CE结合跟踪查找基址 [转]OD 跟踪调试经验 查看发包数据bp Send 修改boot.ini使W3wp使用更多的物理内存 查找游戏帐号 查找选中怪ID相对于基址的偏移 提醒精灵.NET 发布 (小技巧九)设置开机运行功能 使用.NET Reflector插件FileDisassembler还原源码! ASP输出WOrd、Excel文件! (小技巧八)计算字符串的长度 修改Windows 2003 的默认上传文件大小!
简单地址重写
Hover · 2005-06-02 · via 博客园 - Hover

 protected void Application_BeginRequest(Object sender, EventArgs e)
  {

   
   
   string strRawUrl = HttpContext.Current.Request.RawUrl;
   string strNewUrl;

   //*******************************************************************************************
   //分类地址重写
   if (Regex.IsMatch(strRawUrl, @"Post.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"Post.aspx", @"ShowClass.aspx\?ClassID=14");

    HttpContext.Current.RewritePath( strNewUrl );
   }
   else if (Regex.IsMatch(strRawUrl, @"Resources.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"Resources.aspx", @"ShowClass.aspx\?ClassID=13");

    HttpContext.Current.RewritePath( strNewUrl );
   }
   else if (Regex.IsMatch(strRawUrl, @"MobileApplications.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"MobileApplications.aspx", @"ShowClass.aspx\?ClassID=12");

    HttpContext.Current.RewritePath( strNewUrl );
   }
   else if (Regex.IsMatch(strRawUrl, @"Server.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"Server.aspx", @"ShowClass.aspx\?ClassID=11");

    HttpContext.Current.RewritePath( strNewUrl );
   }

   else if (Regex.IsMatch(strRawUrl, @"DataBase.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"DataBase.aspx", @"ShowClass.aspx\?ClassID=10");

    HttpContext.Current.RewritePath( strNewUrl );
   }
   else if (Regex.IsMatch(strRawUrl, @"WebServices.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"WebServices.aspx", @"ShowClass.aspx\?ClassID=7");

    HttpContext.Current.RewritePath( strNewUrl );
   }

   else if (Regex.IsMatch(strRawUrl, @"WindowsApplications.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"WindowsApplications.aspx", @"ShowClass.aspx\?ClassID=6");

    HttpContext.Current.RewritePath( strNewUrl );
   }

  else if (Regex.IsMatch(strRawUrl, @"WebApplications.aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"WebApplications.aspx", @"ShowClass.aspx\?ClassID=2");

    HttpContext.Current.RewritePath( strNewUrl );
   }
   //**********************************************************************************************
   //显示详细文章地址重写
   else if (Regex.IsMatch(strRawUrl, @"(\d+).aspx", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"(\d+).aspx", @"ShowPost.aspx\?id=$1");

    HttpContext.Current.RewritePath( strNewUrl );
   }
   else if (Regex.IsMatch(strRawUrl, @"ShowPost.aspx\?id=(\d+)", RegexOptions.IgnoreCase))
   {
    strNewUrl = Regex.Replace(strRawUrl, @"ShowPost.aspx\?id=(\d+)", @"$1.aspx");

    HttpContext.Current.Response.Redirect( strNewUrl );
   }
}
前面是重写。后面是逆操作.
效果见HTtp://ithero.net