Hosting Multiple Domains on one IP Address
By Erick Stover
You know, I thought I was saving money. It was only a one-time fee of $10.00 for
parked domains, and a monthly $20.00 fee per domain to have a complete sub domain.
At the moment, I have about six different domains in my name. This was not a tough decision to
There was one little problem, though. All of these domains pointed to the same IP address!
No matter what domain name a user typed in, it went to the same site. What was a little code guy to do?
Well, he would code.
And code he did.
I'm sure SOME of you out there have been in a similar situation at one time or
another. You need a seamless way of getting the user to the appropriate area. You
also need to have different meta tags depending on the site. After all, you want
all your sites on the search engines, right?
I didn't want a page that would use
Response.Redirect to send them where they want
to go. That takes too long to load plus they can see the redirect. I wanted one Page that just displays
the appropriate code.
Then, in a strange whispering voice (that sounded strangely similar to that voice
in Field of Dreams), I heard the word "Frames".
I'll just create a single framed frameset and just set the frame src equal to whatever page
I want!. There's no freaky-looking reload and the entire site address is easily masked.
Boy I'm tired of being this good.
OK, enough of an introduction, let's get to the code!
I started with the domain detection.
dim file 'the file name
dim siteId 'just a number I assigned to each site.
'Now I use the request serverVariables to get the address
'they typed in their browser.
if Request.ServerVariables("SERVER_NAME") = "www.dragonden.net" or _
Request.ServerVariables("SERVER_NAME") = "dragonden.net" then
'Quick note, you have to specify the two different versions of your
'domain name. Not everybody uses the "www", others use it religiously.
'The server can't tell the difference between the two unless you give
'it a hint.
file = "dn7.asp"
siteId = 1
elseif Request.ServerVariables("SERVER_NAME") = "www.3dguru.com" or _
Request.ServerVariables("SERVER_NAME") = "3dguru.com" then
file = "http://www.mp3.com/3dguru/"
siteId = 2
elseif Request.ServerVariables("SERVER_NAME") = "www.darkhorizon.org" or _
Request.ServerVariables("SERVER_NAME") = "darkhorizon.org" then
file = "dh/index.asp"
siteId = 3
elseif Request.ServerVariables("SERVER_NAME") = "www.dragondes.com" or _
Request.ServerVariables("SERVER_NAME") = "dragondes.com" then
file = "dd/index.asp"
siteId = 5
'if it can't figure out what they typed, just send them to the main area
file = "dn7.asp"
siteId = 1
The main part is done. Now we need to do something about those pesky search engines.
As far as I know, search engines access your site much in the same way that a
browser accesses it. So I make a case statement with the meta tags. I also threw in
the title tags for kicks.
<%Select Case siteID%>
<meta http-equiv="Keywords" content="rant dragon net editorial
background photoshop tutorials poetry stories flash animation">
<meta http-equiv="Description" content="The Homepage for Dragon Net.
A society of web designers and computer experts. This is my world.">
<meta http-equiv="Keywords" content="techno music electronic industrial
<meta http-equiv="Description" content="The Music Maker of Dragon Net">
<meta http-equiv="Keywords" content="photoshop graphic design animation
presentation 3d studio max art">
<meta http-equiv="Description" content="The Graphic artists of Dragon Net">
<title>Dark Horizon Studios</title>
<meta http-equiv="Keywords" content="asp html coldfusion xml dhtml
<meta http-equiv="Description" content="The Code Masters of Dragon Net">
Finally, we create the frameset. This was a lot easier than I thought. The one
thing to remember is that you need to use the Frameset tags instead of the body
<frameset rows="99%, 1%" frameborder="NO" border="0"
<noframes> <!--For early browsers that can't handle frames. Let
those users know how you feel.-->
<body bgcolor="white" text="black">
This site uses frames. If you don't have a frames capable browser,
go get one. <br>
Otherwise, you're not allowed on my site. Go! Get outta here!!!
There you have it, a simple page that can save you some money, or at least a few
Attachments:Download the ASP source code in text format
Read Charles Carroll's tutorial: Using
Server Variables to Determine Domain
Erick Stover, age 21, is the webmaster and designer
of Dragon Net. He is also the president of
Dragon Designs and Dark Horizon Studios.