![]() |
Web Development »
Client side scripting »
General
Intermediate
Domain redirect using JavaScriptBy Marco AscensãoHow to Redirect a Domain to a file or directory using JavaScript |
JavascriptWin2K, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||
<HEAD> </HEAD> tags of the
index.html
/ index.htm (Apache) or default.htm / default.asp (IIS/PWS) file to redirect
the Domains to their respective web page.dnsX variables with the Domains you wish to redirect
and change their respective location.href<BODY> tag call
the JavaScript function using the "OnLoad" event:
<BODY onLoad="gotoPage()">
<script language="JavaScript"> <!-- function gotoPage() { var dns1 = "natura-travel.com" var dns2 = "montepe-club.com" var dns3 = "natura-act.pt" var dns4 = "levadas-veredas.com" var dns5 = "madeirawalks.com" var dns6 = "nature-walks.com" var urlloc = location.href var loc = urlloc.toLowerCase() if (loc.indexOf(dns1) != -1) location.href="http://www.Natura-Travel.com/natura-travel.htm" if (loc.indexOf(dns2) != -1) location.href="http://www.MontePe-Club.com/montepe-club.htm" if (loc.indexOf(dns3) != -1) location.href="http://www.Natura-Act.pt/natura.htm" if (loc.indexOf(dns4) != -1) location.href="http://www.Levadas-Veredas.com/levadas-veredas.htm" if (loc.indexOf(dns5) != -1) location.href="http://www.MadeiraWalks.com/levadas-veredas.htm" if (loc.indexOf(dns6) != -1) location.href="http://www.Nature-Walks.com/nature-walks.htm" } //--> </script>
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 29 Oct 2001 Editor: Nishant Sivakumar |
Copyright 2001 by Marco Ascensão Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |