防止直接访问mp4(IE / Edge忽略HTTP_REFERER)



我想在我的网站上显示视频(mp4),但想阻止直接访问(example.com/videos/vide1.mp4)。我设法将限制添加到视频文件夹的.htaccess:

RewriteEngine on 
RewriteCond %{HTTP_REFERER} !^https://(www.)?example.com [NC] 
RewriteCond %{HTTP_REFERER} !^https://(www.)?example.com.*$ [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com.*$ [NC] 
RewriteRule .*.(gif|png|mp4)$ https://www.example.com/ [L]

这适用于Firefox/Chrome/...但是在IE或Edge上,我收到错误"无效来源",并且视频未显示在网站上。看起来IE/Edge忽略或使用不同的HTTP_REFERER?这个问题有什么解决方案吗?

有很多工具或浏览器或"匿名器"可能会阻止引用者。
哪些浏览器/插件阻止发送 HttpReferer?

您可以使用:

RewriteEngine on
# This line is the equivalent of your 4 lines
RewriteCond %{HTTP_REFERER} !^https?://(www.)?example.com [NC] 
RewriteRule .(gif|png|mp4)$ - [F,L]

最新更新