Nice answer from Doc while I was writing all of the stuff below. I'll post it anyway.
The codes themselves are part of a set of codes know as HTTP status codes. HTTP is "Hypertext Transfer Protocol," which is a way of sending and retrieving information across the web. When a web server receives a request from a browser, or spider, or other program, it receives that request in a specific format, and the format is defined by the Hyper Text Transfer Protocol.
The web server will normally send a response back to that request, and that response is also defined by a number of rules that are described by the Hypertext Transfer Protocol. There's a whole big section of the World Wide Web Consortium (W3C) website that describes how HTTP
works, but we really only need to look at part of that.
Part of the response that is sent back to a request includes a status code. The status code helps the browser or spider or other program know what to do with the request. Usually a response will start out with a status, which includes:
The version of HTTP being used on the computer responding
The status code
A short description of the status code.
So, you might see something like this:
HTTP/1.1 200 OK
In that status response, the status code is "200" which means OK, I'll send you what you are requesting. Another one that you might have heard of, and have seen is "404" which means "not found."
The W3C has definitions
for the HTTP status codes that might be helpful in understanding how they work, and why search engines might react to them the way that they do.
The definition for a 301 http status code:
301 Moved Permanently
The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.
The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).
If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.
The definition for a 302 http status code:
The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.
The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).
If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.
So, a 301 status code says, "hey, the page that you were looking for is no longer here, you should go over there at this new address to get it from now on."
A 302 status code says, "The page isnt' here, but is going to be over at this other address for a little while. That may not be the permanent new home for it, so keep checking back here."
Both Scottie and Ian are right, in what they say. Scottie is writing about maintaining the rankings for the old address, and the search engine should keep the old address in its index as the address of record for the page, since the new address is only temporary, and could change right back, or move to somewhere else.
Ian notes that if you want the search engine to try to move the pagerank/link popularity to the new address, that you should use a 301 redirect. Where he talks about avoiding using a temporary redirect in the beginning of the quote, he is talking about a 302 redirect, and states that the use of that type of redirect can confuse a spider and slow down a search engine in moving a value to the new address.
Redirects can be within a site, though I prefer if people make changes to the links themselves if they can. It's sort of like a bandaid instead of a solution.
If you change to a new domain, you can set redirects for pages of the old domain to point to pages on the new domain. If you use a 301 redirect, the search engine will start looking at the new address when it sees the old address, and should carry over any pagerank to the new address. If you use a 302 redirect, it will think that this is only temporary, and will keep the pagerank at the old address, even though people will get to the new page.
Matt describes the way that Google responds to temporary redirects in his post. It keeps the old URL, but indexes the content on the new URL being pointed towards:
Okay, back to our regular discussion. Now letís talk about off-domain 302 redirects. By definition, those are redirects from one domain A.com to another domain B.com that are claimed to be temporary; that is, the web server on A.com could always change its mind and start showing content on A.com again. The vast majority of the time that a search engine receives an off-domain 302 redirect, the right thing to do is to crawl/index/return the destination page (in the example we mentioned, it would be B.com).
Note that he then writes that this is what happens most of the time. Sometimes it doesn't. In rare events, they make exceptions, and sometimes that may result in the hijacking of a domain.
Ideally, if you want to move to a new domain, and you want to give yourself time to gain some new links, and want to try to have old links repointed to the new address, you hold on to the old domain and server for a while, and use 301 redirects to point to the new pages on the new domain.
Depending upon the software used on the server you are using to redirect the http requests for one page, to another, there are a few ways make that redirect happen. Under Apache 1.3, there's one method, which is detailed here: http://httpd.apache....s.html#redirect
One of the important statements on that page is this one:
If no status argument is given, the redirect will be "temporary" (HTTP status 302). This indicates to the client that the resource has moved temporarily.
So, it's possible to do a redirect without stating that it is a 301 or a 302 redirect, and if you don't it will be a 302 (temporary) redirect by default. The same is true under Apache 2.0.
On a windows server, using IIS, it's possible to set a redirect for each page. It's important when doing that to check off that it is a permanent redirect. There's also a few programs that will imitate
the redirect, like Isapi Rewrite
I haven't worked with asp to do a rewrite, but I hope the above helps you a little.