Web redirection and "cloaking" with classic ASP script

NOTE: This article is specific to Classis ASP script
Other versions of this article are available for:
ASP.NET

NOTE: You can also the web redirection and cloaking using the HTTP Redirector plug-in.

Some ISPs offer "web redirection" service, where they will redirect web-requests for your domain name to another website.
For example from www.myname.com to www.ispname.com/~myname
or from www.myname.com to myname.ispname.com.

You can do simple redirection with CNAME (alias) DNS records, but this does not work if you need to redirect to a sub-directory (like the first sample above), or if the destination web-server is using virtual hosting (multiple domain names on the same IP address).

Domain redirection is most often done on a web-server with some type of script.
(often in combination with a database if redirecting many domain names)

You can do this with ASP script on IIS or PWS.

First create a DNS A-records for the domain name pointing to the IIS/PWS web-server that will do the redirection (not the destination web-server).

Then create a "default.asp" page on this web-server with the following contents:

<%
Select Case Request.ServerVariables("HTTP_HOST")
Case "myname.com", "www.myname.com"
  Response.Redirect "http://www.ispname/~myname"
Case "othername.com", "www.othername.com"
  Response.Redirect "http://www.ispname/~othername"
End Select
%>

Add "case" statements for each domain name you want to redirect.
You can automate this further with a database containing each domain name and corresponding redirect destination.

On IIS you can also point 404 errors (page not found) to this ASP page so requests for individual pages will also be redirected correctly.

Another variant of this is called "cloaking" - where your domain name still shows in the browser's address bar even after the redirection.
This is achieved by "hiding" the redirection in a frame-set where the first frame is zero width or height:

<%
Select Case Request.ServerVariables("HTTP_HOST")
Case "myname.com", "www.myname.com"
  destURL = "http://www.ispname/~myname"
Case "othername.com", "www.othername.com"
  destURL = "http://www.ispname/~othername"
End Select
%>
<html>
  <frameset cols="0,*" framespacing="0" border="0" frameborder="0">
    <frame name="zero" scrolling="no" noresize>
    <frame name="main" src="<%=destURL%>">
  </frameset>
</html>

REFERENCES:
For more information, please see the following knowledge base articles:

KB Article HTTP Redirector Plug-In
KB Article Web redirection and "cloaking" with ASP.NET

Feedback

Add Feedback
Thanks for the information on this topic. I have been using simple DNS for almost a year now and it has been doing real fine but i have a major request, how do i redirect all http traffic in my local network to my intranet domain name?. I run a local network within a small community, i need Simple DNS to redirect all request to the homepage so as to make the services running on the network known to new users automatically without having to master the URL. thanks i will really appreciate your response.
segun (December 9, 2013 at 2:54 PM)

Add Feedback