The 301 and 302 codes are the HTTP status codes used for redirection. These codes indicate that another request must be made in order to fulfill the HTTP request — the content is located elsewhere. When a web page replies with either of these codes, it does not return any HTML content, but includes an additional Location: HTTP header that indicates another URL where the content is found.

301

The 301 status code indicates that a resource has been permanently moved to the new location specified by the Location: header that follows. It indicates that the old URL is obsolete and should replace any references to the old URL with the indicated URL.

When loading the page in a web browser, the response will be automatically redirected to the new location specified by the Location header. After the redirection, the back button in your browser won’t reference the initially requested page, as a result of the old page being permanently redirected.

The 301 status code also indicates to search engines that link equity from the previous URL should be credited to the new one. In theory, the new page will inherit the rankings of the original page. In practice, however, it may take some time for this to occur. It would be wise not to frivolously change URLs regardless, if this is a concern.

302

The 302 status code is a bit ambiguous in meaning. It indicates that a resource is “temporarily” moved. The old URL is not obsolete at all, and clients will not cache the result unless indicated explicitly by a Cache-Control or Expires header. To confuse things even further, 302 is also used for some paid advertising links, but that is not the usage discussed here. The big problem with the 302 status code is that its meaning for search engines depends on its context. In practice, it is worth dividing them into internal temporary redirects, that is, from a page on domain A to another page on domain A, and external temporary redirects, from a page on domain A to a page on domain B. Browsers always abide by the definitions for interpreting a 302 redirect — both internal and external.
However, today, most search engines only use it for an internal 302. For an internal 302 redirect, then, search engines will not cache the result of the redirect, and continue to list domain A in the SERPs. This is consistent with the definition. External 302 redirects are more of a problem. Matt Cutts of Google states that more than 99% of the time, Google will list the result with the destination result, that is, domain B, instead of domain A. This is against the standard, and Google behaves like this to mitigate a vulnerability called “302 hijacking.”