SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Allowing only certain sources to site

    I have this page that I only want viewed from another site. So for example theirsite.com has the link to mysite.com. If the link is coming from their domain it lets them through. But say someone try to go to the link directly to mysite.com, I want them to be fowarded to another page stating they cant view it.

    Is this:

    a) Possible in PHP?
    b) If so then how? Using HTTP functions in PHP?

    Thanks
    Silly

  2. #2
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works well for me...
    PHP Code:
    <?php 
    if ($HTTP_REFERER != "http://www.yourdomain.com/images/index.php")

    header("Location: http://www.yourdomain.com/cannot_view.php");

    ?>
    Lats...

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    You could try using .htaccessS as well but its a whole lot easier with PHP.

    Also, you might want this code instead
    PHP Code:
    <?php 
    if ($_SERVER['HTTP_REFERER'] != "http://www.yourdomain.com/images/index.php" )
        
    header("Location: http://www.yourdomain.com/cannot_view.php" ); 
    ?>

  4. #4
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Time I updated my code snippets
    Lats...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •