Want to work with us? We're on the lookout for a Magento Developer.

We're hiring

301 redirect without touching IIS (VB.NET)

Web Bureau

10 October 2011 by Web Bureau

Just a method of doing a 301 redirect from non-www to www I came across rather than doing it through IIS

            Dim requestedDomain As String = HttpContext.Current.Request.Url.ToString().ToLower()

            If InStr(requestedDomain, "") Then

                requestedDomain = requestedDomain.Replace("", "")

                Response.Status = "301 Moved Permanently"
                Response.AddHeader("Location", requestedDomain)

            End If

        Catch ex As Exception
            Response.Write("Error in Global.asax :" & ex.Message)
        End Try

Grow your businessStart a project with us today.