Saturday, May 20, 2006

URL Redirection basics for IIS

Source: http://blogs.msdn.com/david.wang/archive/2005/08/01/HOWTO_Common_URL_Redirection_Techniques_for_IIS_Summary.aspx

The web server can perform three types of redirection to handle any given request from the client:

  1. Client-Side Redirection - The server sends a "302 Redirect" response with a Location: header containing the new URL, and the client makes another request to the new URL.
  2. Server-Side Redirection - The server transparently rewrites the request URL to another URL which remains on the same website as the original.
    (This Redirection is also known as CourtesyURL/Pretty URL/URL shadowing/URL masking Publishing or Exporting internal website to be accessible externally/Redirecting URL on one web server to be handled by another web server/One web server reverse-proxying another server/Force HTTP requests to HTTPS/SSL )
  3. Server-Side Forwarding - The server transparently rewrites the request URL to another URL which does NOT remain on the same website as the original. Note the new website can be on another machine, but not necessarily.

    Some people classify these types depending on the URL refresh. But its not correct.

Apache never has built in URL redirections. You need to install and configure add-on modules like mod_redirect to get Client-Side Redirection, mod_rewrite to get Server-Side Redirection, and mod_proxy to get Server-Side Forwarding. These are embedded into the httpd.config and .htaccess includes.

IIS Core has built-in Client-Side redirection and configurable via the HttpRedirect property. You need to install add-on modules to get Server-Side Redirection and Server-Side Forwarding behavior.

Redirection possibilities and technology to perform:

  1. Client-Side Redirection using:
    IIS "Core" (no code) - HttpRedirect
    IIS "Core" (script code) - HttpErrors and ASP
    ASP (script code) - Response.Redirect
    ISAPI Filter (compiled code) - SF_REQ_SEND_RESPONSE_HEADER
    ISAPI Extension (compiled code) - HSE_REQ_SEND_RESPONSE_HEADER, HSE_REQ_SEND_URL, HSE_REQ_SEND_URL_REDIRECT_RESP
  2. Server-Side Redirection using:
    IIS "Core" (no code involved) - IIsWebFile and ScriptMaps
    ASP (some code involved) - Server.Transfer and Server.Execute (ASP only)
    ISAPI Filter (compiled code) - SetHeader( "url" ) in SF_NOTIFY_PREPROC_HEADERS or SF_NOTIFY_AUTH_COMPLETE
    ISAPI Extension (compiled code) - HSE_REQ_EXEC_URL and HSE_REQ_EXEC_UNICODE_URL and Wildcard Application Mapping
  3. Server-Side Forwarding using:
    ISAPI Filter (compilied code) - Using WinHttp
    ISAPI Extension (compiled code) - Using WinHttp and Wildcard Application Mapping

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete