Monday, 29 September 2014

Microsoft: URL Rewrite VS HTTP Redirect

The main difference between rewriting the URL and redirecting is the following. Redirecting sends a HTTP 301 or 302 to the client, telling the client that it should try to access the page using another URL. This means that the client knows that there is another URL that should be used. The communication between the server and client is illustrated as follows:
Request 1 (from client):    Get file.htm
Response 1 (from server). The file is moved, please request the file newFileName.htm
Request 2 (from client):    Get newFileName.htm
Response 2 (from server): Here is the content of newFileName.htm

Rewriting happens on the server, and simply is a translation of one URL to another, that is used by your web application. The client does not know that internally there is another URL, it just sees the one it sent to the server.
Request 1 (from client):       Get file.htm
URL Rewriting (on server):   Translate the URL file.htm to file.asp
Web application (on server): Process the request (run any code in file.asp)
Response 1 (from server):    Here is the content of file.htm (note that the client does not know that this is the content of file.asp)


Reference:
How does "URL Rewrite" differ from "HTTP Redirect"
http://forums.iis.net/t/1174487.aspx?How+does+URL+Rewrite+differ+from+HTTP+Redirect+

No comments:

Post a Comment