开发者

How to prevent hotlinking of flv files?

开发者 https://www.devze.com 2023-02-01 15:31 出处:网络
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 do

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号