How to do a 301 Redirect in using Visual Basic

So you have a new domain or you have changed the structure of your website but you don’t want your visitors to get the dreaded 404 page because the page they are looking for no longer exists.

The best thing you can do is setup a 301 redirect to the pages new location. The 301 redirect accomplishes two things, one it tells all of the search engines that the page has been moved permantly to a new location and second it automatically redirects your user to the new page.

By using a 301 redirect you will make sure that your new page retains the same page ranking with the search engines and most importantly allow your visitors to find what the correct content. On to the code…

Insert the following code into the head of your aspx page. You also need to add a form tag to the page with the runat=”server” setup. Please remember this is setup for an page using visual basic, not C#.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.Status = "301 Moved Permanently"
End Sub

Leave a Reply