简体   繁体   English

保护public_html中的文件夹

[英]Protecting folder in public_html

I have a music sharing site and realize that the files on my site are not necessarily protected as they are stored in a subfolder in public_html. 我有一个音乐共享网站,并意识到我的网站上的文件不一定受到保护,因为它们存储在public_html的子文件夹中。 I need to protect them in a way that they still work for anyone in the music player, which located on a listen.php page. 我需要保护它们的方式,它们仍然适用于位于listen.php页面的音乐播放器中的任何人。 However, if the user goes directly to a file, such as this http://www.pearlsquirrel.com/mp3/95d246c26a7c003cdac86ead05659b37.m4a . 但是,如果用户直接转到某个文件,例如http://www.pearlsquirrel.com/mp3/95d246c26a7c003cdac86ead05659b37.m4a I do not want them to be able to download the file so as to protect my users. 我不希望他们能够下载文件以保护我的用户。 However, I can not add any code to that page because it is an mp3. 但是,我无法向该页面添加任何代码,因为它是一个mp3。 Is there a way to add an index to the folder that would allow for me to add javascript to that page? 有没有办法在文件夹中添加一个索引,允许我将javascript添加到该页面? I tried using .htaccess but had no luck with it. 我尝试使用.htaccess,但没有运气。 If anyone knows how I could possibly solve this problem, it would be greatly appreciated. 如果有人知道我怎么可能解决这个问题,我将不胜感激。 Thanks! 谢谢!

Stu Thompson在这篇文章中解释了一些方法 - 保护Flash视频免受下载/权利保护 ,这个链接对您来说可能特别有用 - 是否可以防止从网站下载视频

try with .htaccess to: 尝试使用.htaccess:

  • forbid directory listing 禁止目录列表
  • check the urlreferrer / remote IP address 检查urlreferrer /远程IP地址

But if, depending on the way you play the file to the user, if there is a direct access to the file, it will be hard to secure. 但是,如果根据您向用户播放文件的方式,如果可以直接访问该文件,则很难保护。

You could rewrite your music file's URLs to a PHP script, check some login via session and output the music file only if the user is logged in. 您可以将音乐文件的URL重写为PHP脚本,通过会话检查一些登录,并仅在用户登录时输出音乐文件。

You could also put a copy of a mp3, that a user is listening to with a session id in the name and remove it after the session get's invalid. 您还可以将名称中包含会话ID的用户正在收听的mp3的副本放入,并在会话获取无效后将其删除。 This way every user has it's own URL that will not be active permanently. 这样每个用户都拥有自己永久不会激活的URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM