Forum Moderators: coopster
Now, i want to be able to check who is the referral of this script:
1. If someone directly put http://www.example.com/img.php?id=1 into their browser and tried to access the image, then the checker will know and return error.
2. If someone hotlink the image with http://www.example.com/img.php?id=1, i want to be able to know the referral website and then decide whether to block or not.
Any idea how?
[edited by: eelixduppy at 3:58 am (utc) on Oct. 17, 2007]
[edit reason] switched to example.com [/edit]
echo $_SERVER['HTTP_REFERER'];
This cannot really be trusted, however, so if you are trying to protect content you may want to think of other means to do so.
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http(s)?://(www\.)?example.com [NC]
RewriteCond %{HTTP_REFERER}!^http(s)?://(www\.)?othergooddomain1.com [NC]
RewriteCond %{HTTP_REFERER}!^http(s)?://(www\.)?othergooddomain2.com [NC]
RewriteRule \.(jpg¦jpeg¦png¦gif)$ justgoaway.jpg [NC,R,L] or do similar logic in your php...
(and if it doesn't work, please spare no details!)