Post by kokenge on Aug 6, 2014 7:27:22 GMT -5
I do this all the time. I have several domains going to the same IP.
I simply look at the domain coming in and direct it to the proper directory.
I display a forwarding message and a title. However unless your server is very busy the message is never displayed long enough for anyone to see it.
This html checks for domain1 and redirects it to the /doamin1 directory.
If it's not domain1 it goes to my catch all default /domain2 directory.
You can add code to check for as many domains as you like.
I'm using the Apache server with a www directory under wamp. So it gets sent to wamp/www/domain1 and runs that index.html
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
<script type="text/javascript">
function urlforward(){
var wl = window.location;
var lh = (location.host);
var lp = (location.pathname);
var lr = (location.href);
if (lh == 'www.domain1.com' || lh == 'domain1.com' || lh == 'domain1' || lh == 'www.domain1') {
window.location = window.location.protocol + "//" + window.location.host + "/domain1";
} else {
window.location = window.location.protocol + "//" + window.location.host + "/domain2";
};
}
</script>
<TITLE>Any Title</TITLE>
</HEAD>
<BODY onLoad="urlforward()">
Redirecting....
</BODY>
</HTML>
Hope this helps.