Want to work with us? We're on the lookout for digital experts.

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.

This site uses essential cookies for parts of the site to operate and have already been set. Find out more about how we use cookies and how you may delete them. You may delete cookies, but parts of the site will not work.