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.

Allowing access to a webpage ONLY when referred by a specific domain

Discussion in 'PHP' started by schlottke, Dec 22, 2004.

  1. #1
    How do I go about allowing access to a webpage ONLY when referred by a specific domain?

    I have a successful checkout URL from paypal where people get a download, but I dont want them to be able to get to that page by just typing it in.

    Im assuming it possible in .htaccess, but can't seem to figure out how.
     
    schlottke, Dec 22, 2004 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    You can do it with .htaccess, but if the page they are trying to get to is PHP, it would be easier to do it within the PHP logic.
     
    digitalpoint, Dec 22, 2004 IP
  3. schlottke

    schlottke Peon

    Messages:
    2,185
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #3
    the page can be PHP, any info out there on how to do this?
     
    schlottke, Dec 22, 2004 IP
  4. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You could use this line to start with
    <?php
    if ( substr_count($_SERVER["HTTP_REFERER"],"url_of_referer")==1) 
    { include ("path_to_download"); }
    else { include("your_error_page"); }
    ?>
    PHP:
     
    mushroom, Dec 22, 2004 IP
  5. Refrozen

    Refrozen Peon

    Messages:
    318
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I recomment using stristr over substr_count, however, that is just me.
     
    Refrozen, Dec 22, 2004 IP
  6. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    "stristr" would require an exact match.

    "substr_count" can be made to ignore subdirectories and "?...."
     
    mushroom, Dec 23, 2004 IP
  7. schlottke

    schlottke Peon

    Messages:
    2,185
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Any way to have to load a cookie so users can access the direct page without needing to go through the gateway?
     
    schlottke, Dec 23, 2004 IP
  8. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #8
    Yeah... with the cookie functions in PHP. :)
     
    digitalpoint, Dec 23, 2004 IP