Forum Moderators: open
This is my situation:
I have three domains pointing to the same IP. At the moment I'm using a very simple web server that has almost no function at all nut it will suffice for the moment. Later I'm getting apache.
This is what I want to do:
Based on what url the user requested I want to redirect the browser to a subfolder so that a user that types "http://www.example-1.com" will end up in the /example-1 subfolder and a user that requests "http://www.exaple-2.com" will end up int the /exaple-2 subfolder although they both point to the same IP.
I've worked out that it's the document.url property I have to work wiht but I have no idea how.
Any takers?
if (document.location.href.indexOf("site1.com")) {
document.location = "http://www.mainsite.com/site1";
} else if (document.location.href.indexOf("site2.com")) {
document.location = "http://www.mainsite.com/site2";
}
Don't use that approach. It will break the users back button. Instead, use location.replace(), which replaces the page in the user's history so that when they hit back they won't keep hitting your redirection page.