Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Hotlink protection: securing PHP-generated images

Discussion in 'General Discussion' started by Kelmas, Jul 1, 2008.

  1. Kelmas

    Kelmas Well-Known Member

    Joined:
    Nov 6, 2006
    Messages:
    121
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Lithuania
    I used cPanel's hotlink protection, which uses mod_rewrite rules, but it protects only static images, like file.jpg, mypicture.gif etc.

    On my system I have a PHP script that generates image, so URL to it is something like image.php?photo=123 where 123 is unique image number. How do I build a rewrite rule to protect this type of image?

    Tried diffrent ways but no luck :confused:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. pross

    pross Well-Known Member

    Joined:
    Mar 14, 2005
    Messages:
    75
    Likes Received:
    0
    Trophy Points:
    156
    surely u could add a line to check that $_SERVER['HTTP_REFERER'] is your server if not deny the image
     
  3. Kelmas

    Kelmas Well-Known Member

    Joined:
    Nov 6, 2006
    Messages:
    121
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Lithuania
    Yes, but maybe there's a way to implement this into .htaccess so that I could have all hotlinking protection in one place...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice