Performing 301 redirects in ASP, ASP.NET and PHP

A 301 redirect is the proper way to not only let your users know a page has changed location but also the way to let search engines know the page has been moved and to update their index.

ASP

<%
  Response.Status="301 Moved Permanently"
  Response.AddHeader "Location", "http://www.NewLocation.com/"
%>

ASP.NET

<script runat="server">
  private void Page_Load (object sender, System.EventArgs e) {
      Response.Status = "301 Moved Permanently";
      Response.AddHeader("Location","http://www.NewLocation.com/");
  }
</script>

PHP

<?php
  header ("HTTP/1.1 301 Moved Permanently");
  header ("Status: 301 Moved Permanently");
  header ("Location: http://www.NewLocation.com/");
  exit(0);
?>