Forum Moderators: coopster
As far as I know if you hotlink-protect your site, ALL request from other site will be rejected, so its not possible to share banner with others.
How can I address this in PHP?
As fas as I can think you can't emulate hotlink protection with PHP.
If someone just went directly to an image e.g. www.yourdomain.com/yourpicture.jpg PHP would never be executed and they would see the picture.
I do know that the Hotlink protection in cPanel on my host you can add in a list of URLs that you'd like to allow Hotlinking so they don't get blocked, fine for a few other websites but not if you've got lots!
Cheers,
Mike
In that PHP file you can do a few things I guess.
1. Try checking the URL. If different than yours, deny.
2. put that file one step higher than the root ../display_image.php
And they won't get the chance to run the PHP file.
Habtom
You would do something like this to prevent hotlinking of images -
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif¦jpg¦js¦css)$ - [F]
replace mydomain.com with your domain name and only your domain will be allowed to access files appeneded by .gif .jpg .js or .css
you can add other allowed domaine with extra lines e.g. -
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain1.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain2.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain3.com/.*$ [NC]
RewriteRule \.(gif¦jpg¦js¦css)$ - [F]
hope this helps
Please clarify if it is really possible. Thanks