Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3964086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:17:31+00:00 2026-05-20T03:17:31+00:00

I am not looking for a simple redirect. What I am trying to do

  • 0

I am not looking for a simple redirect.

What I am trying to do is this.

Person A loads site BOB.com and clicks a link to page X.
Person B loads site TIM.com and clicks a link to the same page X.

Page X has a javascript command on it that says, If user came from site Bob.com then redirect to Bob.com/hello.
If user came from TIM.com then redirect to Tim.com/hello.
If user didnt come from ether then redirect to Frank.com/opps.

This page X is going to handle 404 errors for multiple domains so it will need to ONLY look at the domain name upto “.com”. It should ignore everything past the “.com”.

This is the script I started with.

<script type='text/javascript'>
var d = new String(window.location.host);
var p = new String(window.location.pathname);
var u = "http://" + d + p;
if ((u.indexOf("bob.com") == -1) && (u.indexOf("tim.com") == -1))
{
u = u.replace(location.host,"bob.com/hello");
window.location = u;
}
</script> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:17:31+00:00Added an answer on May 20, 2026 at 3:17 am

    Use document.referrer

    if(/http:\/\/(www\.)?bob\.com/.test(document.referrer)) {
       window.location = "http://bob.com/hello";
    }
    
    else if(/http:\/\/(www\.)?tim\.com/.test(document.referrer)) {
       window.location = "http://tim.com/hello";
    }
    
    else {
       window.location = "http://frank.com/oops";
    }
    

    Instead of the regex, you can use indexOf like you did initially, but that would also match thisisthewrongbob.com and thisisthewrongtim.com; the regex is more robust.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at a simple, programmatic way of detecting whether or not the user
I'm looking for a simple C# solution to manage a playlist. Not the actual
I am looking for a simple way to redirect the public/index.html to the app/views/public/index.html.erb
This is what I am trying to achieve but I'm not familiar with the
I'm looking for a simple xhtml page sample where all markups are used. I
This seems like it should be a simple problem. I'm trying to host my
I'm looking for educational material on the subject of scalability analysis. I'm not simply
I'm not looking for a full implementation, I'm more interested in how they do
I'm not looking for java-web-start, I'm looking for a thick-client application installation toolkit. I've
I'm not looking for the usual answer like Web-services. I'm looking for a light

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.