Hello, I have 2 different websites/domains on 1 IP. The problem is that whenever stuff is uploaded, it displays in both sites.

Example: site_1.com/page.php = site_2.com/page.php

I created a directory for each site.

Example: site_1.com/site_1 and site_2.com/site_2 .

I want to create a script that resides as the index of the IP and directs the viewer to the proper directory by what URL they typed in.

For example: If they typed in site_1.com it would take them to site_1.com/site_1 and if they typed in site_2.com it would take them to site_2.com/site_2.

Can someone show me how to do this please? It's slightly urgent....

stuff concerning domains and what folder they are directed to has to deal with server configuration. there is no need to make a script to do this for you.

Yes, but I can't configure the server as it's not mine. I have seen this done with Javascript but the downside was it didn't work in FF.

try this:

<script type="text/javascript">
var href = window.location.href;
if (href == 'http://yoursite.com/') {
window.location='site_1/index.html';
}
else {
window.location='site_2/index.html';
}
</script>

i just typed it. i think it will work

try this:

<script type="text/javascript">
var href = window.location.href;
if (href == 'http://yoursite.com/') {
window.location='site_1/index.html';
}
else {
window.location='site_2/index.html';
}
</script>

i just typed it. i think it will work

Thanks. It didn't work in FF though so I tried this:

<script type="text/javascript">
var href = window.location.href;
if (href == 'http://snowmanlady.com/') {
window.location='Main/index.htm';
}
if (href == 'http://movingtargetdesigns.com/') {
window.location='DesignMain/index.htm';
}
</script>

This works in IE but not in FF. Suggestions?

P.S. I tried to up your rating and accidentally hit 'disprove' . Sorry. D*mmit.

i tried it on six different browsers and they all worked. firefox worked just fine when i typed in your url. what exactly is the problem? it maybe the version, thats the only thing i can think of.

i found a problem. if the user uses www in front of the url it doesn't work. you need to add these to the javascript code.

<script type="text/javascript">
var href = window.location.href;
if (href == 'http://snowmanlady.com/' || href == 'http://www.snowmanlady.com/') {
window.location='Main/index.htm';
}
if (href == 'http://movingtargetdesigns.com/' || href == 'http://www.movingtargetdesigns.com/') {
window.location='DesignMain/index.htm';
}
</script>

Thank you so much! I don't know what I would have done! I specialize in CSS and XHTML, not Javascript (I'm just starting to learn it :) ). By the way, I like this script so much I want to share it. If you PM me your name and stuff I would like to submit it to JS source sites. This is the only cross-browser version I have seen, and I'm sure others have had this problem to. Again, Thanks a million!:icon_cool:

Why are you fussing with scripts? Just include the folder name in the published url:

www.thisismydomain1.com/site1foldername/site1page.htm
www.thisismydomain2.com/site2foldername/site2page.htm

Because this makes a cleaner, more professional look.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.