Virtual Hosts, Javascript, Abyss X1

Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message

Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Sat Jan 06, 2007 8:27 am    Post subject: Virtual Hosts, Javascript, Abyss X1 Reply with quote

Virtual Hosts and Javascript

Here is a small tutorial explaining how to declare a new virtual host and how to associate it with a domain name using Javascript.

(I kinda used the same instruction structure for creating hosts by aprelium, after searching I noticed a PHP redirect function too that's a sticky... this does it with javascript although PHP may be better)

* create a directory in your hard drive where the files of the web site will be stored. In this example we'll use an Abyss Web server and that you will create a new directory (folder) called ''\website1\'' inside "c:\mysites\"

* create an ''index.htm'' file and ''index.js'' file with URL detect Javascript and redirect functions

* How to access it and test it.

>1> First Register

* must be a valid registered domain name. Use your registrar's tools, to configure DNS name to point to your computer's IP address. Here you can have and or more point to the same IP address: --> -->

>> Create a Directory for ''/website1/'' and ''/website2/''
Copy your files and folders to those websites
You should have a directory like this when done..
|_ website1
|_ website2
|_ website3
|_ website4

>2> In the directory ''c:\mysites\ create a new index.htm and a new index.js file.

Copy the following HTML code into your ''index.htm'' document


<html xmlns="" xml:lang="en" ><head>
 <script type="text/javascript" language='javascript' src='index.js'></script>
 </head><body onLoad='ReDirectURL();' ></body></html>

Copy the following Javascript Code into your ''index.js'' document


var yourdomainUrl = new Array (
  new Array (''    , 'website1/index.htm')
, new Array (''    , 'website2/index.htm')
, new Array (''    , 'website3/index.htm')
var thisURL = document.location.href;
function ReDirectURL() {
    for (i=0;i<=yourdomainUrl.length; i++) {
        if ( thisURL == yourdomainUrl[i][0]) { document.location.href = yourdomainUrl[i][0] + yourdomainUrl[i][1]; }

Your directory should look something like this.

|_ index.htm
|_ index.js
|_ website1
|_ website2
|_ website3
|_ website4

>3> Change to your real domain name in ''index.js''

If your real domain name is '''' then make the change as follows:

   new Array (''   , 'website1/index.htm')
,  new Array (''    , 'website2/index.htm')

If your real domain name has more than one name ie

then make the changes as follows:


    new Array ('' , 'website1/index.htm')
,   new Array ('' , 'website1/index.htm')
,   new Array ('' , 'website1/index.htm')

Save the changes.

>4> Test ''yourdomain1'' and see if it is accessing ''website1''

Use an external website such as or use your best friends computer across the street or next door to test if '''' is accessible from the internet.

>5> That's it!
Todd (Gannyaa)
Back to top View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials All times are GMT + 1 Hour
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB phpBB Group