IIS7 URL Rewriting Module Replace

前端 未结 5 671
再見小時候
再見小時候 2020-12-07 03:33

I really like the IIS7 URL rewriting module and so far, it worked great for me.

There is one thing that I\'m not sure how to do: I would like to permanently redirec

5条回答
  •  旧时难觅i
    2020-12-07 04:01

    One of then nice things about .aspx is how easy it is to rewrite URLs with real code. Just add a little search and replace code to your web site's Global.asax file:

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        string path = HttpContext.Current.Request.Path;
        // Search and replace, RegEx, etc.
        HttpContext.Current.RewritePath(path);
    }
    

    On IIS7, you have to add some entries in web.config to handle rewriting non .aspx URLs:

    
        
            
            
            
            
    

    The IIS7 URL rewriting module is great, but just because you have a hammer...

提交回复
热议问题