Your code basically redirect the request if the URL contains mysite.com to www.mysite.com I think when you request mysite.com/default.aspx, it will redirect to www.mysite.com/default.aspx. Bruce DiscountASP.NET www.DiscountASP.NET
Hi I'm trying to solve the canonicalization issue. If I put the following code in the global.asax file, it redirects from http://mysite.com to http://www.mysite.com/Default.aspx How can I get it to redirect to the root without the /Default.aspx and without causing an endless loop. Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) If (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http://mysite.com")) Then Dim myURL As String myURL = HttpContext.Current.Request.Url.ToString().ToLower() myURL = Replace(myURL, "http://mysite.com", "http://www.mysite.com") HttpContext.Current.Response.Status = "301 Moved Permanently" HttpContext.Current.Response.AddHeader("Location", myURL) End If End Sub thanks. Michael.
Then you must have some other redirect code at play here. What is the site's default document, is it default.aspx? And is there any redirect logic there as well? Aristotle DiscountASP.NET www.DiscountASP.NET
Bruce, what I mean is if i type http://mysite.com why does it redirect to http://mysite.com/Default.aspx?