1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How Do I Show the Domain By Which Someone Was URL-Forwarded to Page?

Discussion in 'PHP' started by Affiliate Programs, Mar 28, 2017.

  1. #1
    I've been researching and trying various methods with no success yet. I want to be able to display a message like this when someone is url-redirected to a page if they type the domain into their address bar:

    "Hi - You were brought here by:" + Example.com

    I guess there are solutions which work if someone clicks a link, but I'm looking to capture and "echo" the info if someone merely does a domain type-in.
     
    Affiliate Programs, Mar 28, 2017 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Eh... and exactly HOW are you supposed to get the name of the site (if any) they were previously on, if they don't click a link? There IS NO referral if they type in the domain in the address bar. Of all the stupid questions...

    Okay, you could do some cookie-sniffing, but that is WAY too involved. Just do a match if there IS a referral link, and if not, say something like "Hey, you managed to type in the address yourself! Yay for you!"
     
    PoPSiCLe, Mar 28, 2017 IP
  3. Affiliate Programs

    Affiliate Programs Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #3
    Well if anyone has the answer I'd appreciate it because this person doesn't know what he's talking about.

    For anyone else who might be confused by this other guy's statement, to reiterate and clarify further I'm talking about url redirection or domain forwarding, from one Example1.com to another Example2.com. So for instance, if the site is on Example2.com and someone types Example1.com into their address bar, with Example1.com taking them to the page at Example2.com via url redirection, then I'd like to be able to echo a statement on the page at Example2.com indicating they were brought to Example2.com via Example1.com.

    I don't even know if this is possible with PHP, but it seems like it should be, or if not perhaps someone can add it to the language before long.

    It's that simple, however, so don't be confused by post #2 there.
     
    Last edited: Mar 28, 2017
    Affiliate Programs, Mar 28, 2017 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #4
    Well, aren't you a charmer. If you'd read through this forum you'd have realised that @PoPSiCLe warrants a bit of respect. He may not have understood your question but that does not justify your attitude.

    If someone types in the domaina.com and gets auto redirected to domainb.com doesn't it show as a referrer in the $_SERVER stats?
    Is the person doing the referring doing something fancy with the server headers?

    There are a few ways you can test this
    1. var_dump($_SERVER) and see if there's anything useful in there
    2. use a server header tool to see what the source server is doing. We used to do this all the time here but have built in the tools and I can't remember the site I used to use. http://www.askapache.com/online-tools/http-headers-tool/ is similar.
    Let us know what you've tried and we'll try and come up with something.
    BTW do you have control over the original domains?
     
    sarahk, Mar 28, 2017 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    If you're talking about URL-redirection, just fetch the information from the SERVER-functions - depending on HOW this redirect is done, it might be straight-forward, or not. Since you provide no code, we can't know. Follow @sarahk's advice, and figure out what you have to work with.

    As for ambigous phrasing - couldn't you just have written "I wanna show the original domain the user typed into the address bar after a server redirect"?
     
    PoPSiCLe, Mar 29, 2017 IP
  6. JEET

    JEET Notable Member

    Messages:
    3,825
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #6
    Try checking what is in $_SERVER['HTTP_ORIGIN']
    Do you see example1.com in there?
     
    JEET, Mar 30, 2017 IP