The 301 redirection is described in RFC2616: The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs.
Browsers automatically follow these redirections. They also display the new permanent address in the address bar.
In accordance with RFC2616, the same address pointed to by the redirection will eventually be saved in the browser favorites.
The standard recommends to use a 301 redirect when a page has been permanently moved to a new address.
301 Redirect and Search Engines
According to RFC2616, search engines should forget the redirecting address and save the address pointed to by the redirection as the preferred address.
When a page has been moved to a permanent new address, Google recommends to use a 301 redirect. But, strangely enough, the leading search engine often needs weeks or months to take this information into account in its search results.
301 Redirect Implemented in .htaccess File
Assuming the web server allows it, it is easy to implement a 301 redirect in .htaccess.
Moving a page
RedirectPermanent /old-file-name.html http://www.new-domain.com/new-directory/new-file-name.html
Moving a directory
RedirectPermanent /old-directory http://www.new-domain.com/new-directory
Moving an entire site
RedirectPermanent / http://www.new-domain.com/
301 Redirect Implemented in a Server Script
The script (typically a PHP, Perl or ASP program) will have to generate a 301 header.
Moving a page in PHP
<?php
header (“Status: 301 Moved Permanently”, false, 301);
header (“Location: http://www.new-domain.com/new-directory/new-file-name.html”);
exit();
?>