Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to redirect to a specific URL based on current url location

Status
Not open for further replies.

dontpunchme

Programmer
Jul 29, 2002
20
US
Hi...

I have two different domain names that point to the same IP address. Example
I am trying to set it up so that if a user types in siteone.com the code on the index page can tell that the location object is siteone.com and redirect them to
If the user types in sitetwo.com I would like the browser to recognize the location and redirect them to
Please help. I am looking for a javascript solution, or .htaccess file code to do the same thing.

Thanks.

Mike
 
How about:
Code:
if(location.href.indexOf('siteone.com')>-1){
  location.href='siteone.html'
else
  location.href='sitetwo.html'
}
 
Thanks for the code... I had to add a couple of { } ... and then it worked like a charm.

Thanks for the help.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top