Two Domains - One IP.

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?
LVL 6
Mach1proAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fritz_the_blankCommented:
If they are getting there via a link, you can use:

document.referrer

Fritz the Blank
0
guildencrantzCommented:
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
fritz_the_blankCommented:
You can do similar things with ASP if you are on a windows host rather than the Apache.

Fritz the Blank
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mach1proAuthor Commented:
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
Mach1proAuthor Commented:
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
kollegovCommented:

var host = document.location.host
alert(host)
0
kollegovCommented:
host = document.location.host;
if( host.toLowerCase() != 'www.primary.com' ) {
   window.location='http://www.primary.com/'+window.location.pathname
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mach1proAuthor Commented:
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
kollegovCommented:
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
Mach1proAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.