Hosting Multiple Domains on one IP Address
By Erick StoverYou 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 make. 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".
THAT's IT!!!
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.
A number of sites run by Charles Carroll use the Response.Redirect method. For example, LearnASP.com,
ASPLists.com, and ASPNG.com all point to the same IP address. If you visit ASPNG.com,
you are automatically redirected to http://www.aspng.com/aspng/. Similarly,
If you visit ASPLists.com,
you are automatically redirected to http://www.ASPLists.com/ASPLists/.
To learn how Charles handles this, be sure to read his tutorial: Using
Server Variables to Determine Domain.
Another (non-ASP) solution is to use Host Headers. For a discussion on using Host Headers be sure to read Robert Black's article: Using Host Headers to Allow for One I.P Address to Host Multiple Domains! |
OK, enough of an introduction, let's get to the code! I started with the domain detection.
|
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.
|
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 tags.
|
There you have it, a simple page that can save you some money, or at least a few headaches!
Happy Programming!
Attachments:
Erick Stover, age 21, is the webmaster and designer of Dragon Net. He is also the president of Dragon Designs and Dark Horizon Studios.




