Redirect 301 for all my posts...by folder to root

Topics: ASP.NET 2.0, Business Logic Layer, Controls, Themes
Nov 11, 2012 at 6:43 PM

time ago I posted my problem 301 redirect from subdirectory to root
Today I added the following function in global.asax and everything seems to work,

    void Application_BeginRequest(object source, EventArgs e)
    {
        HttpApplication app = (HttpApplication)source;
       // HttpContext context = app.Context;
        
        string thisUrl = app.Request.Url.ToString().ToLower(); 

		if (thisUrl.Contains("http://www.informarea.it/blogengine"))
		{				

		HttpContext.Current.Response.Status = "301 Moved Permanently";
		HttpContext.Current.Response.AddHeader("Location",thisUrl.Replace("http://www.informarea.it/blogengine","http://www.informarea.it"));
		}
		HttpContext context = app.Context;        
        
        
        // Attempt to perform first request initialization
        FirstRequestInitialization.Initialize(context);
    }

when i write www.informarea.it/blogengine, redirect work fine,

when i write www.informarea.it/blogengine/post/..... i don't have redirect but i see the post and i dont have error...

very strange...  ... do you think there is something wrong with these lines of code '?