Posted on: 5/17/2014 7:22:28 PM | Views : 381

Hi,
For some reason I can't figure out what I'm doing wrong here. (I'm trying to redirect a portion of a site to a new domain) All requests to the old domain folder keep trowing 404-page not found exeptions instead of a nice 301 redirect to the new domain.
Here's my code. Any ideas?
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) Dim url As String = Request.RawUrl.ToString() If url.StartsWith("http://www.olddomain.be/projecten") Then HttpContext.Current.Response.Clear() HttpContext.Current.Response.Status = "301 Moved Permanently" HttpContext.Current.Response.AddHeader("Location", url.Replace("www.olddomain.be", "www.newdomain.be").ToLower) End If End Sub

Go to the complete details ...