301 redirect happens when a page has been moved/removed and is no longer available. When this happens, you can direct the user to the new page location and explicitly state for the crawlers that the page has been permanently moved to the new location
ASP Coding
<%
‘ Indicate permanent redirection
Response.Status = “301 Moved Permanently”
Response.AddHeader “Location”, “http://www.mysite.com”
Response.End
%>
PHP Coding
<?
header( “HTTP/1.1 301 Moved Permanently” );
header( “Location: http://www.mynewsite.com” );
?>
302 redirect is the redirect that takes place on successful form submission or matching certain loop criteria.
ASP Coding
<%
Response.redirect “http://www.mysite.com”
%>
PHP Coding 302 redirect
<?php
header(‘Location: http://www.mysite.com/’);
exit();
?>