If you read my other post, you know about the problems I have had getting a client set up with multiple domains hosted under the same 1&1 account. 1&1′s decision to market their hosting as “have as many domains as you want” is misleading at best, because they require that each domain point to the same place. You have to handle ALL multiple domain requests using a coded solution. This isn’t ideal for far too many reasons to list here, but I figured I could offer someone some help if they are running into the same problem.

Pre-Conditions

  1. First you have to have all of your files set up correctly.  The correct way is to have a sub-directory for each site that you want to host under the account.  You may have better luck, but I couldn’t get directory names with dots in them to work (just another thing on the long list).
  2. Once you have your files set up, you need to make sure that each site’s domain is pointed to the account root.  Not the sub-directory that you have created for the site.

Primary Redirect File

Now, in the account root directory, you need a file called default.asp that will include code similar to the following:

1
2
3
4
5
6
7
8
9
<%EnableSessionState=False
  host = Request.ServerVariables("HTTP_HOST")
 
  if host = "domain1.com" or host = "www.domain1.com" then
    response.redirect("http://domain1.com/domain1-directory/default.aspx")
  elseif host = "domain2.com" or host = "www.domain2.com" then
    response.redirect("http://domain2.com/domain2-directory/index.shtml")
  end if
%>
Your sites will now technically work.  But wait, there’s more!  What if you want to have custom error pages for each site?

Custom Error Pages

Of course, there’s more hoops to jump through.  This can’t be done on the server side because the default IIS error files are .html files.  So you basically have to fool IIS into using your files by naming them the name that IIS uses by default.  Then, you have to use code similar to the following to make sure sites redirect whenever an error page is hit.  Yes, I know this isn’t ideal, but the entire account is now a hack because 1&1 sucks, so I’ll live with it until I convince everyone to abandon 1&1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>Error!</title>
		<script type="text/javascript">
			if (location.hostname == "domain1.com" || location.hostname == "www.domain1.com") {
				window.location = "http://www.domain1.com/domain1-directory/404.shtml";
			} else if (location.hostname == "domain2.com" || location.hostname == "www.domain2.com") {
				window.location = "http://domain2.com/domain2-directory/error404.html";
			}
		</script>
	</head>
	<body>
	</body>
</html>

After All…

While my preference would be to never have to deal with this crazy hack-happy format for having an account with multiple domains, I will undoubtedly run into this again.  Who knows, maybe someday you will to and this article will prove helpful.  I guess, in the end our world is all about hacking solutions into place, right?  ;)