?
Solved

Two Domains - One IP.

Posted on 2003-03-26
11
Medium Priority
?
212 Views
Last Modified: 2006-11-17
I am having a new website set up. The customer will have two different Domain Names that
point to the same IP address.  Is there anyway to use Javascript on the Home page to
determine which domain name the surfer used to get to the server and redirect to a new page
if they used the secondary name?
0
Comment
Question by:Mach1pro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8213835
If they are getting there via a link, you can use:

document.referrer

Fritz the Blank
0
 

Expert Comment

by:guildencrantz
ID: 8214703
Why are you trying to do this with javascript?  This is something that is much more effeciently handled by most web servers (*cough*Apache*cough*) under the name "virtual host".  I currently have about five different domains running happily side by side with Apache doing all the folder direction for me.

~~Guildencrantz
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8214750
You can do similar things with ASP if you are on a windows host rather than the Apache.

Fritz the Blank
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Author Comment

by:Mach1pro
ID: 8214852
I am on a windows server.
I would rather do this with Javascript where the code would be in the index page and only change the location if the individual entered under a particular domain name.
I would be open to doing it in asp if there isn't a good javasrcipt alternative.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 8215041
0
 
LVL 6

Author Comment

by:Mach1pro
ID: 8215141
acperkins,
I have submitted six of these questions to CS for Deletion and accepted the answers on several others. I will try to make an effort to sort through the comments on the other questions in the next few days. None of the ones left have a clear definitive answer or else I would have already accepted them.
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8215240

var host = document.location.host
alert(host)
0
 
LVL 10

Accepted Solution

by:
kollegov earned 1000 total points
ID: 8215268
host = document.location.host;
if( host.toLowerCase() != 'www.primary.com' ) {
   window.location='http://www.primary.com/'+window.location.pathname
}
0
 
LVL 6

Author Comment

by:Mach1pro
ID: 8233532
Experts,
I'm still waiting on the second domain name for this account to propogate. It should of already been done, but for some reason it hasn't.  That's why I haven't been able to test any of your suggestions yet. I haven't forgotten this question.
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8236074
you do not really need to have 2 real domain to test,  you can
use one you have as SECONDARY one and place page here with DUMMY primary one in code
like www.yahoo.com
Your page will redirect to Yahoo  dummy :-)

Then test same code on your server, but with your existing domain as PRIMARY   in code
and it wouldn't do redirect from primary to DUMMY yahoo



0
 
LVL 6

Author Comment

by:Mach1pro
ID: 8291359
The reason why the domain didn't propogate was due to a misspelling in the registration. That's been corrected and I should be able to test the solutions in the next couple of days. While it may be possible to test without the actual name, I've learned never to take anything for granted. Just because a code works in a simulated environment, doesn't mean it will work in the actual situation it was designed for.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question