Running multiple sites (using Javascript)

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


Joined: 08 May 2004
Posts: 23

PostPosted: Thu Sep 23, 2004 4:55 pm    Post subject: Running multiple sites (using Javascript) Reply with quote

It is possible to run multiple sites in Abyss using a short Javascript code in the header of your index.html page. Using Java over PHP does have its advantages. In PHP, your script must be configured to detect domain.com as well as www.domain.com or it won't work. If a user enters www.domain.com/page1.html, they won't be redirected unless the PHP script is configured with that address. With the Javascript below, the URL (however entered into the user's browser) will redirect to the proper directory.

PHP also requires that your main (index.html) page be renamed to index1.html, or home.html, or whatever. With Java, if the need for a redirect is not detected, the index.html page will be displayed as normal.

Insert the following Javascript into the header (between <HEAD> and </HEAD>) of your main (index.htm) page. Just below the <TITLE> line is a good place...

<SCRIPT LANGUAGE="JavaScript">
var refarray = new Array();
refarray['DomainOne.com'] = "DirectoryOne";
refarray['DomainTwo.com'] = "DirectoryTwo";
refarray['DomainThree.com'] = "DirectoryThree";
refarray['DomainFour.com'] = "DirectoryFour";
for (var i in refarray) {
if (document.URL.indexOf(i) != -1) window.location.replace(refarray[i]);
}
</script>

Now, simply change the variables to reflect the URL (such as aprelium.com) to be redirected, and the directory containing the website for that URL. Do not enter the URL prefixed by 'WWW.' - simply enter the domain name. Do not use a slant or backslash before or after the directory name - simply enter the name of the directory.

Give it a try!

Claude
Back to top View user's profile Send private message
HIWD
-


Joined: 13 Apr 2004
Posts: 142
Location: Dublin, Ireland

PostPosted: Fri Oct 01, 2004 9:42 pm    Post subject: Reply with quote

Thanks for the script man, its really simple and it works prefect. Did you make this yourself?
Back to top View user's profile Send private message Visit poster's website
Axis
-


Joined: 29 Sep 2003
Posts: 336

PostPosted: Sat Oct 02, 2004 12:03 am    Post subject: Reply with quote

Hi Claude--

Will search engines be able to follow the javascript? Many search engines have trouble with javascript.

Regards,
Axis
Back to top View user's profile Send private message
cldickerson
-


Joined: 08 May 2004
Posts: 23

PostPosted: Tue Oct 05, 2004 12:15 pm    Post subject: JavaScript Reply with quote

Thanks. Yep, it's a pretty simple script. I prefer it to the PHP coding. And, no - search engines will probably not be able to follow the script, but then they would have the same problem following the PHP script.

Claude
Back to top View user's profile Send private message
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Wed Oct 06, 2004 2:37 am    Post subject: Reply with quote

search engines do not follow javascript. A band-aid for the problem is to use <noscript> tags for search engines to follow.

example:

<noscript>
<a href =http://www.mysite.com/main.html>mysite.com</a>
<a href =http://www.hissite.com/default.html>hissite.com</a>
<a href =http://www.hersite.com/enter.html>hersite.com</a>
</noscript>

and add a meta tag for robot directions

<meta name="robots" content="index,follow">

search engines will be able to follow if you do this.

search engine robots will be able to follow any server side script unconditionally.
Back to top View user's profile Send private message Visit poster's website
WolfRamiO
-


Joined: 30 May 2004
Posts: 121
Location: Viña del Mar, Chile

PostPosted: Thu Dec 23, 2004 5:26 pm    Post subject: Reply with quote

i find a detail, if your browser doesn´t have java script enable, the server just show the srcipt lines >B^p... because client browser do as compiler.
Back to top View user's profile Send private message Visit poster's website
cldickerson
-


Joined: 08 May 2004
Posts: 23

PostPosted: Fri Dec 24, 2004 3:16 am    Post subject: Reply with quote

You mean that there is actually someone left on this planet who is running a browser that doesn't support Java?
Back to top View user's profile Send private message
WolfRamiO
-


Joined: 30 May 2004
Posts: 121
Location: Viña del Mar, Chile

PostPosted: Fri Dec 24, 2004 3:25 am    Post subject: Reply with quote

yeah!
Back to top View user's profile Send private message Visit poster's website
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Fri Dec 24, 2004 5:04 pm    Post subject: Reply with quote

cldickerson wrote:
You mean that there is actually someone left on this planet who is running a browser that doesn't support Java?


no most do, but some users chose to disable Java/JavaScript for security reasons. For example in my browser, I've set it to run JavaScripts, but not Java.
_________________
Olly
Back to top View user's profile Send private message
UtahLugers
-


Joined: 13 Jan 2005
Posts: 7
Location: USA

PostPosted: Fri Jan 28, 2005 1:59 am    Post subject: Reply with quote

I know I may be bringing this back from the dead and I should brush up on my javascripting but if someone knows a lot about this and can do it fast, that would be way cool.

I know the problem with this script (and the PHP script?) is that it will redirect to another directory making it harder to host multiple sites. Now, i'll have to look at the coding again but i'm sure that we could add in some code where the output is (where it says to redirect the page) and instead put in some if/then coding saying: IF it is xxbb.com then proceded to __(line xx or whatever)___ (coding w/ document.write (" frames etc") ). If it is NOT xxbb.com, continue... IF it is NOT xxcc.com continue, IF it is xxdd.com, go to the correct coding.

The only problem with this is (that I can see); if someone types xxbb.com and then views the source, they will see all this coding of the redirect?
_________________
This is me....I don't want to be like you.
Back to top View user's profile Send private message Visit poster's website AIM Address MSN Messenger
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