How to make a page open only if it has a specific refferal.

Discussion in 'PHP' started by kapaionutz, Jan 18, 2012.

  1. #1
    Hy webmasters!
    I want to upload a file on my webhost, but i want to make it downloadable only if the page has a specific refferal.

    Can anyone help me with a kind of script for that?

    EDIT: solved:
     
    Solved! View solution.
    Last edited: Jan 18, 2012
    kapaionutz, Jan 18, 2012 IP
  2. #2
    if you mean the website that visitor came from so here yo are

    if($_SERVER['HTTP_REFERER'] == 'http://www.google.com'){
        header("location:ref_page.php");
    }else{
            header("location:index.php");
    }
    
    Code (markup):
    or

    
    $website = "google.com";
    $match = strpos($_SERVER['HTTP_REFERER'], $website);
    if( $match === true){
        header("location:ref_page.php");
    }else{
        header("location:index.php");
    }
    
    Code (markup):
     
    Last edited: Jan 18, 2012
    yho_o, Jan 18, 2012 IP