Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Two Domains - One IP.

Posted on 2003-03-26
11
Medium Priority
?
213 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

578 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