How do I point a second domain to a sub-directory or sub-web of my site?
Normally, domains can only be setup so that they point to the root directory of your web site. However, using ASP code, you can detect which URL a person is browsing to your site with, and redirect them to the appropriate place on your site. Here is some sample ASP code that will do the job. You will want to put this code at the very top of an .ASP page (generally, the default page of the primary domain) before any HTTP tags:
<%
sname = Request.ServerVariables("SERVER_NAME")
sname = ucase(sname)
if InStr(sname,"DOMAIN1") <> 0 then
response.redirect "subdirectory to go to"
elseif InStr(sname,"DOMAIN2") <> 0 then
response.redirect "2nd subdirectory to go to"
end if
%>
--------------------------------------------------------------------------------
Make sure that the domains in the InStr commands are capital letters.
--------------------------------------------------------------------------------
For example, suppose you have two domains, apple.com and banana.com, pointing to the same web site.
On this site there is an "appledir" subdirectory (or sub-web) and a "bananadir" subdirectory.
Then the code will look like this:
<%
sname = Request.ServerVariables("SERVER_NAME")
sname = ucase(sname)
if InStr(sname,"APPLE") <> 0 then
response.redirect "appledir"
elseif InStr(sname,"BANANA") <> 0 then
response.redirect "bananadir"
end if
%>
If you have only two domains and you still need the primary domain to point to the root of the site then you can use this code:
<%
sname = Request.ServerVariables("SERVER_NAME")
sname = ucase(sname)
if InStr(sname,"DOMAIN2") <> 0 then
response.redirect "directory2"
else
response.redirect "index.html"
end if
%>
You can substitute the "index.html" to whatever your default page is.