About A Webmaster - What You Need To Know

301, 302 and You

May 3, 2005

That's right, your web server (or htaccess file if you don't have direct access to your web server) can take care of all of these issues when used properly. Every time your web browser requests a web page, the web server will respond with a numbered code called an HTTP Status Code. The most commonly recognized HTTP response code is the 404 code, which means that the document you are trying to retrieve cannot be found. So what does all of this have to do with redirects? A few of those codes are used to indicate that a document has moved. These are the ones that will help us with our redirection issues. The W3C has a detailed breakdown of all the HTTP status codes including 301 and 302 redirects.

The 301 and 302 redirects are used to automatically redirect a web request. They do this in a somewhat similar fashion as a meta refresh, but add context to the redirection. The end result is that when a person uses a bookmark or types in the old URL, they are automatically redirected to the new URL, but with no intermediate page. The lack of an intermediate page means that only the HTTP header is sent back to the client to let them know about the redirection. The small size of the http header helps to speed up the process to the point where most often, it is a near instantaneous redirection, with very little to no sense of lag for the end user.

The context that a proper HTTP redirect provides comes from the specific status code it returns. A 302 redirect is used when the resource in question exists under a different URL temporarily, but you want people to continue to use the original URL with which the request was made. For example, if you have a daily column on your site, you might want to maintain a URL such as http://mysite.com/column/current/. In this case, we want the URL to redirect to the permanent URL of the article, http://mysite.com/column/37.html but tomorrow, we'll want to change the target of the "current" URL redirect to http://mysite.com/column/38.html. We want people to continue using the http://mysite.com/current/ URL to get the current column, whatever that might be. Hence, a temporary redirect.

The 301 redirect is a permanent redirection. It indicates that the resource has moved permanently and people should update their information for this URL. While the casual surfer who has your site bookmarked will be seamlessly redirected, the more technically savvy members of your audience will get an extra bit of information, notifying them that they should update their links and other information. Some of those technically oriented audience members are the search engine robots. Modern search engines will read a 301 redirect and update all associated properties of the old document to its new location. Any inbound links to the old URL will have their search engine ranking values attributed to the new page.

Page 3 of 4