How do I handle secondary domain aliases in ASP?

The most common way to process a secondary domain alias using ASP code is to use the incoming host header value to select a redirect page.

The incoming host header is stored in the server variable "HTTP_HOST", and the Redirect method of the Response object is used to perform the redirection.

For example, the following code will examine the host header and redirect to a subfolder.

Option Explicit
Response.Buffer = True

Dim HostURL
HostURL = Lcase(Request.ServerVariables("HTTP_HOST"))

Select Case HostURL ' Find which site to redirect to
Case "", ""
Case "", ""
Case "", ""
End Select


If you use relative URL's in your Redirect statements as shown above, the client browser will continue to use the original alias domain name. In other words, by using URL's like "/this" or "/that" the original alias domain name will appear in the client web browser URL bar after the redirect has completed.

If your redirect parameter looks like "http://www.this.that" then the value in the client browser will show the full URL used in the redirect, not the one from the original request to your alias.

Add Feedback