如何动态密码保护文件(图片,视频,ZIP)来自公共和只允许访问成员? [英] How to password protect files (images, video, zip) dynamically from public and allow access to members only?

查看:163
本文介绍了如何动态密码保护文件(图片,视频,ZIP)来自公共和只允许访问成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个普遍的问题,解决了很多次,但由于某些原因,我无法找到正确的信息。

It's a common problem, solved many times, but for some reason i cannot find the right information.

一些限制和要求:


  • 技术的LAMP堆栈。

  • 细粒度控制哪些文件可以访问。

  • 由htpasswd文件没有基本的身份验证,我想提供一个自定义登录前端。

  • 应能安全地保护和服务于大的视频文件

如何做所有这些网站保护自己的文件从公共不使用基本身份验证?

How do all those sites protect their files from public without using basic authentication?

谢谢!

有一个类似的问题:<一href=\"http://stackoverflow.com/questions/1688568/performance-oriented-way-to-protect-files-on-php-level\">http://stackoverflow.com/questions/1688568/performance-oriented-way-to-protect-files-on-php-level

推荐答案

您通常会重定向媒体文件到PHP脚本的任何请求。在PHP脚本执行登录认证,并成功使用加载从受保护的位置请求的媒体文件,并通过浏览器通过它,例如 fpassthru() FREAD()

You would usually redirect any requests for the media files to a PHP script. The PHP script does the login authentication, and on success, loads the requested media file from a protected location, and passes it through to the browser, for example using fpassthru() or fread().

您可以使用一组的mod_rewrite 指令,例如改写建立一个非常优雅的解决方案。

You can set up a very elegant solution using a set of mod_rewrite instructions, for example rewriting

www.example.com/media/music.mp3

在内部

www.example.com/media/index.php?file=music.mp3

方法并不便宜,作为PHP间preTER必须启动对每个下载,并穿过文件的每个字节。对于可能的替代方案的讨论,我问了一个关于一个几个月前的问题:<一href=\"http://stackoverflow.com/questions/1688568/performance-oriented-way-to-protect-files-on-php-level\">Performance-oriented方式来保护PHP级 文件?

这篇关于如何动态密码保护文件(图片,视频,ZIP)来自公共和只允许访问成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆