How can I use ASP to ReDirect a user based on the domain name?

Domain Names
This information is useful when you have multiple domains pointing to your IP and you want to redirect to the proper page according to domain name. The following ASP Script shows a simple way to redirect based on the domain name: 

  Dim HTTPHost
  HTTPHost = Request.ServerVariables("HTTP_HOST")

  If InStr(Request.ServerVariables("HTTP_HOST"), "") Then
     Response.ReDirect ""
  ElseIf InStr(Request.ServerVariables("HTTP_HOST"), "") Then
     Response.ReDirect "/subfolder/"
     Response.ReDirect ""
  End If

You can place this script as your default.asp and place your web content in sub-webs or subdirectories.

Add Feedback