我可以选择哪些选项来防止图像/视频的异地链接

发布于 2024-10-17 04:52:03 字数 160 浏览 7 评论 0原文

在工作中,我正在构建一个用于上传用户视频的表单,他们希望包含一个选项,您可以在其中指定是否允许您的视频嵌入到另一个网站上。有没有办法防止视频/图像被其他网站查看和下载?

我见过当图像托管在某个地方并且该帐户只分配了这么多带宽时,就会发生这种情况。

我什至不知道如何标记这个。

At work I am building a form for uploading a user video and they want to include an option where you can specify if you want to allow your video to be embedded on another web site. Is there a way to prevent the video/image from being viewed and downloaded from another web site?

I've seen it happen with images when they are hosted somewhere and the account only has so much bandwidth allocated to it.

I don't even know how to tag this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奢欲 2024-10-24 04:52:03

是的,你可以。这取决于您想要限制访问的级别。如果您只想限制来自其他网站的嵌入(但不介意其他人无论如何都可以下载视频),解决方案可以是观看引用标头。

像这样的伪代码:

 $headers = getallheaders();
 $referer = $headers['Referer'];

 if( !checkReferer($referer) ){
    //don't admit, request coming from other website
 } else {
   //allow
 }

干杯!

Yes you can. It depends at what level you want to limit the access. If all you want is to limit embedding from other websites (but don't mind that others can download the video anyway) a solution can be to watch the referer header.

Something like this pseudo-code:

 $headers = getallheaders();
 $referer = $headers['Referer'];

 if( !checkReferer($referer) ){
    //don't admit, request coming from other website
 } else {
   //allow
 }

Cheers!

但可醉心 2024-10-24 04:52:03

在 WordPress 网站上面临相同的要求,并设法使用 htaccess 指令来做到这一点:

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteCond %{HTTP_REFERER} !^https://(www\.)?mydomain\.com/ [NC]
  RewriteRule ^wp-content/uploads/2024/04/video\.webm$ - [F]
  RewriteRule ^wp-content/uploads/2024/04/video\.mp4$ - [F]
  RewriteRule ^wp-content/uploads/2024/04/video\.ogv$ - [F]
</IfModule>

Faced the same requirement on a Wordpress website and managed to do it using htaccess instructions:

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteCond %{HTTP_REFERER} !^https://(www\.)?mydomain\.com/ [NC]
  RewriteRule ^wp-content/uploads/2024/04/video\.webm$ - [F]
  RewriteRule ^wp-content/uploads/2024/04/video\.mp4$ - [F]
  RewriteRule ^wp-content/uploads/2024/04/video\.ogv$ - [F]
</IfModule>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文