Link to home
Start Free TrialLog in
Avatar of Mach1pro
Mach1pro

asked on

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?
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

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

document.referrer

Fritz the Blank
Avatar of guildencrantz
guildencrantz

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

Fritz the Blank
Avatar of Mach1pro

ASKER

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.
Please maintain your open questions:
I am not going to hold my breath.  For the record the following questions are still open:
https://www.experts-exchange.com/questions/20547007/How-can-I-trap-a-Row-s-delete-in-Excel.html
https://www.experts-exchange.com/questions/20542975/Programmatically-change-WordDoc-on-a-report.html
https://www.experts-exchange.com/questions/20541929/Use-Kodak-image-control-in-reports.html
https://www.experts-exchange.com/questions/20447990/Keep-Hidden-forms-hidden.html
https://www.experts-exchange.com/questions/20442724/How-to-read-contents-of-Macros-using-VBA.html
https://www.experts-exchange.com/questions/20425624/Photos-designed-for-Access-with-256-colors.html
https://www.experts-exchange.com/questions/20420285/Maximum-number-of-relationships.html
https://www.experts-exchange.com/questions/20343765/fpHover-class-in-Netscape-6.html
https://www.experts-exchange.com/questions/20439753/Change-Activesync-settings-via-VB.html
https://www.experts-exchange.com/questions/20371159/Include-App-on-SendTo-menu-during-installation.html
https://www.experts-exchange.com/questions/20390136/Cannot-'Send-Message-Later'-in-Netscape-7.html
https://www.experts-exchange.com/questions/20403479/multiple-swf-files-play-when-browser-requires-scroll-bars.html
https://www.experts-exchange.com/questions/20388225/Control-the-downloading-of-several-movie-files.html
https://www.experts-exchange.com/questions/20485836/Connection-Time.html
https://www.experts-exchange.com/questions/20372447/refer-to-Access-Network-question-in-Access-area.html
https://www.experts-exchange.com/questions/20403705/make-Frontpage-ignore-scripts.html
https://www.experts-exchange.com/questions/20397535/Update-one-Access-database-from-another.html

Anthony
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.

var host = document.location.host
alert(host)
ASKER CERTIFIED SOLUTION
Avatar of kollegov
kollegov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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



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.