How do 301 redirections work?

When you're trying to reach a page on the web, your browser send a GET request to the server that hosts this page. This request simply consist of the name of the file to display and the version of the HTTP protocol you use to retrieve this information. GET request also involves other pieces of information, such as referer or user agent, but they have no impact on a 301 redirect process.

GET /original_address.htm HTTP/1.1
Host: www.domain.com

In the case of a 301 redirect, the server should be answering something like the following codes. This example is coming from a Microsoft IIS 6.0 server.

Server Response: 301 Moved Permanently
Date: Sat, 17 Nov 2007 13:10:55 GMT
Server: Microsoft-IIS/6.0
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 241
Location: http://www.domain.com/new_page_address

When recieving this kind of answer, your browser will automatically send another GET request to the server with the address of the redirected location set in the original answer. You will then access the target content on its new URL.



Creative Commons License
This site is available uder Creative Commons licence.