How to, using PHP and/or .htaccess prevent hotlinking?
There's a site, which is allowed to access the flv files located on my server, however I've noticed that there are many requests from other domains as well...
Here's the actual rule:
RewriteCond %{HTTP_REFERER} !^http://alloweddomain.com/.*$ [NC]
RewriteRule .flv den开发者_运维百科ied.php [NC,L]
It's working OK except for Firefox, because FF is not sending referrer info when accessing .flv files...
Add a condition for blank referrers:
RewriteCond %{HTTP_REFERER} ^$ [OR]
RewriteCond %{HTTP_REFERER} !^http://alloweddomain.com/.*$ [NC]
RewriteRule .flv denied.php [NC,L]
http://www.htaccesstools.com/hotlink-protection/ is a good place to start.
Also allow requests with no referrer at all. Some firewalls also block referrers.
精彩评论