This was an outstanding tip from PC Magazine I felt should be shared. Basically, using a small VB Script in your index page on your site, you can re-route visitors based on what domain they request. This is only useful if you have more than one domain (i.e. bfarber.com AND bfarber.net) but many people do now-a-days.

I have edited the article for simplicity, but overall the content comes from Jay Munro with PC Magazine.
Many hosts offer a service in your site control panel that allows you to "park" a domain. Well, what is this exactly? Simple...it basically means more than one domain name can point to the same site. Many people today buy ALL of the top-level domain names (i.e. .com, .net, .org, .info, etc.) and want to point them at the same site. Some people buy common misspellings of domain names so that if a user types a misspelled domain name in, they will still get where they want to go. Well, most hosts allow you to sign up for service with one domain name, and then "park" the others from your site control panel later on (check with your hosting provider if you are unsure how to do this, or if you are unsure if they offer this service).
Well, what do you do if you want to point ONE to one site, and ANOTHER to a different site? Say, for example,
bfarber.com should point to a store (.com is commercial after all) and bfarber.info should point to our help files. Certainly your host will let you pay them more money to get a second service, a second IP (or a second dns entry) and you can do it that way....however who wants to pay the money for something you can legally and easy do for free.
I will show an example in ASP (as that is the example provided in the article) and in PHP (the language I script in).
When you visit a site, many things about your browser is recorded...one such thing that we are concerned with is the HTTP_HOST you are requesting...or the name that you typed in the address bar in other words.
In ASP, the following script will look at this host, and redirect you based on what host you requested:
CODE
<script language='vbscript' runat='server'>
urlhost = Request.ServerVariables("HTTP_HOST")
select case urlhost
case "www.firstsite.com"
Response.Redirect("first/index.htm")
case "firstsite.com"
Response.Redirect("first/index.htm")
case "secondhost.com"
Response.Redirect("secondsite/index.htm")
case "www.secondhost.com"
Response.Redirect("secondsite/index.htm")
case "www.thirdsite.com"
Response.Redirect("thirdsite/index.htm")
case "thirdsite.com"
Response.Redirect("thirdsite/index.htm")
case else
Response.Redirect("myindex.asp")
end select
</script>
Without going into too much detail (which most of you looking for this will care nothing about) the script takes the host you request and redirects you based on the hostname.
You would want to take the above code and enter ONLY this in your Index.asp file which should reside in your root directory...this will allow the script to execute and do what it is supposed to do seamlessly so that the user knows little of what is going on behind the scenes.
There are many other variables that can be used to determine where to redirect people as well...some include the operating system and browser (HTTP_USER_AGENT), the language someone's OS reports (HTTP_ACCEPT_LANGUAGE), and the site a visitor is coming to your site from (useful for tracking affiliate hits--HTTP_REFERER).
PHP is very similar to ASP and can do the same things. I developed the following on my own based on the example above (haven't tested...please let me know if you try it and find you are having any problems.
In your index.php page in your root directory, you would want to enter the following code and ONLY the following code:
CODE
<?php
$host = parse_url($_SERVER['HTTP_HOST']);
switch($host['host']){
case 'firstsite.com' :
header("Location: http://" . $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) . "/first/index.htm");
break;
case 'www.firstsite.com' :
header("Location: http://" . $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) . "/first/index.htm");
break;
case 'secondsite.com' :
header("Location: http://" . $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) . "/secondsite/index.htm");
break;
case 'www.secondsite.com' :
header("Location: http://" . $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) . "/secondsite/index.htm");
break;
case 'thirdsite.com' :
header("Location: http://" . $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) . "/thirdsite/index.htm");
break;
case 'www.thirdsite.com' :
header("Location: http://" . $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) . "/thirdsite/index.htm");
break;
default :
header("Location: http://" . $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) . "/myindex.php");
break;
}
?>
The reason the PHP code looks so much tougher is that HTTP/1.1 requires an absolute URI for the Location header to work, but in the script I have provided above this should be generated automatically based on the requested HOST, your php's root directory, and the hostname used (which points to the correct path). Once again, I have not tried the above as I only have one domain name here, but if anyone does and finds problems with this script etc. feel free to let me know.
In general the two scripts should work the same way and produce the same output (though of course one running under ASP and the other under PHP.
I found this article to be quite intriguing, as I hope you have too.