reject a visitor based on the site that referred them - how to?

Discussion in 'PHP' started by loopline, Dec 3, 2007.

  1. #1
    Hello all. I have a question. I would like to know if it is possible to reject or accept a visitor based on who referred them. I am asking for direction as much as I am the answer. I would research it, but I don't even know what this would be called. Here is what I mean.

    I have a site. xyz.com and I am getting visitors to the site from this site:

    tttttt.com
    and
    direct browser type in the url traffic

    Now I want to allow the users from ttttt.com (secure site) - the traffic is coming from various sub pages, but I want to be able to allow the traffic from the entire domain.

    but not allow the direct browser type in traffic.

    Does this make sense? How would I do this? I presume it can be done with PHP? Thanks much in advance for your help.

    Thank you very much in advance for your help.

    MAtt
     
    loopline, Dec 3, 2007 IP
    selling vcc likes this.
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to know the referrer first : $_SERVER['HTTP_REFERRER']

    Then use the function parse_url($_SERVER['HTTP_REFERRER']) to retrieve the domain name and the page path.

    Then check the page path with a preg_match() to see what you'll display to the visitor.

    I can write a small code for you if you give more details about what you want you script to block/allow
     
    selling vcc, Dec 3, 2007 IP
    loopline likes this.
  3. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #3
    I do NOT know any PHP solution - there might be one however.
    BUT
    I belief this could as well be a problem that could be solved using apache configuration directly.
    hence if you get NO solution HERE in this thread - have a look at the apache experts section or even mod_rewrite section.

    may be all coming from your specific referrer get what they need
    all others = rewrite to a default OTHER page OR get an access denied page

    you may also meanwhile look thru the apache documents
    assuming you have 2.2
    http://httpd.apache.org/docs/2.2/

    if you get NO reply at all then you may PM nintendo for a mod rewrite solution to your problem as I belief there might be one for a true rewrite expert using apache config features
     
    hans, Dec 3, 2007 IP