•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,504 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,683 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1630 | Replies: 9 | Solved
![]() |
•
•
Join Date: Aug 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
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....
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....
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
try this:
i just typed it. i think it will work
<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
•
•
Join Date: Aug 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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>P.S. I tried to up your rating and accidentally hit 'disprove' . Sorry. D*mmit.
Last edited by RGStrat : Sep 28th, 2007 at 11:25 pm.
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
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> Last edited by kkeith29 : Sep 28th, 2007 at 11:46 pm.
•
•
Join Date: Aug 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
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!
). 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! 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
Last edited by MidiMagic : Sep 29th, 2007 at 3:47 pm.
Daylight-saving time uses more gasoline
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Error msg ' Operation Aborted' when accessing some websites. (Web Browsers)
- IE6 Browser Window closes when accessing certain websites (Web Browsers)
- How do you design cool programs/websites i.e. colour, shapes etc... (HTML and CSS)
- estimated prices on websites (IT Technologies and Trends)
- Problems loading websites (Web Browsers)
- Certain websites cannot be accessed (Web Browsers)
- "Cannot find server, DNS error" when viewing some links on some websites (Viruses, Spyware and other Nasties)
- Virtual Hosting Multiple Websites (Linux Servers and Apache)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: java Script Problem
- Next Thread: Need help implementing a javascript function



Linear Mode