Click here to return to the NetworkActiv Web Server description page
Click here to return to the NetworkActiv Web Server FAQ page
Running multiple domains using JavaScript is a relatively easy task. Using a simple text editor such as Notepad or Wordpad, copy and paste the following HTML text into a new text file.
<HTML>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
// This code by NetworkActiv.
// Only permitted for use with NetworkActiv Web Server
// (c)2005 NetworkActiv
if(window.location.href == "http://www.MY_FIRST_DOMAIN_NAME/" ||
window.location.href == "http://MY_FIRST_DOMAIN_NAME/")
window.location = "/MY_FIRST_DOMAIN_ALIAS_PATH/";
else if(window.location.href == "http://www.MY_SECOND_DOMAIN_NAME/" ||
window.location.href == "http://MY_SECOND_DOMAIN_NAME/")
window.location = "/MY_SECOND_DOMAIN_ALIAS_PATH/";
else{
document.write("Unkown Domain Name:<BR>");
document.write(window.location.href);
}
</SCRIPT>
</BODY>
</HTML>
After you paste this text into the text editor, replace all of the MY_FIRST_DOMAIN_NAMEs with your first domain name (ie. networkactiv.com, and likewise replace all of the MY_SECOND_DOMAIN_NAMEs with your second domain name. You may notice that on there are two places for each. This is because each has a www version and a non-www version. The reason for this being that many sites can be accessed via either one.
After you are done with that, replace the MY_FIRST_DOMAIN_ALIAS_PATH with your first domain's alias path, and likewise replace the MY_SECOND_DOMAIN_ALIAS_PATH with your second domain's alias path. As you may be able to guess, you will need to create an alias path for each of your domain names. What you specify as the alias path in NetworkActiv Web Server will need to be the same as what you replace these parts of the code with.
A quick note: It is best to enter your domain names in lower case. The Alias path however, must be entered in the exact same case as it was created with. This is because you can have multiple alias paths with the same name but different case.
If you wish to run more than two domains, you will need to copy and paste the three (3) lines of code that originally contain the term SECOND_DOMAIN. The copy of these three lines should be pasted directly under (with a blank line in between) the three lines from which they were copied. You can repeat this process as many times as need to support all of the domains you wish to run.
Now, once you have modified the code correctly and have created alias paths for each of your domains, you need to create a blank alias path that references the folder that will contain the new text file. Do this by adding a new folder but when asked for the Alias path, leave it blank.
Now, it's time to save the new text file. Save it as index.html. For it to save the file with the correct file extension, you may need to choose the All Files option from the Save as type: dropdown list on the Save or Save as dialog.
Make sure that you save the file in the folder that is referenced by the blank alias path that you have created. If all is well and all has been done correctly, when you access any of the domains using the domain name in the browser (ie. www.networkactiv.com), the browser should automatically re-direct to the correct alias path for the domain name entered. If the domain name does not match any specified in the code, a simple page will be displayed and will display the domain name entered into the browser. This helps with determining exactly what the code sees the name as.
Editor's note: It is very important that you do not accidently delete the wrong characters (letters and stuff) from the code when editing it. A single missed or mis-modified character can easily cause the code to not work correcly (if at all). Be sure to pay close attention to things like letter-case, slashes, dashes and the like. You may need to modify the code a few times before you get it to do exactly what you want. Be sure to try the code when you are done with it, do not assume that your modifications were correct.