简体   繁体   English

拒绝直接访问文件夹中的文件

[英]Deny direct access to files in folder

My client has a requirement: 我的客户有一个要求:

  1. She wants to create private pages in wordpress with embedded media files (images or videos) 她想在Wordpress中使用嵌入的媒体文件(图像或视频)创建私人页面。
  2. User should not be able to download those media files directly by using the urls but those image should be shown on the private pages. 用户应该不能直接使用url下载那些媒体文件,但是这些图像应该显示在私人页面上。

I know I can make pages private and put a password on folder using .htaccess but have no idea about the points above. 我知道我可以将页面设为私有,并使用.htaccess将密码放在文件夹中,但对以上几点一无所知。 The site is on Linux Server. 该站点位于Linux Server上。

Any idea about this? 有什么想法吗?

With .htaccess there is a way to check the REFERRER. 使用.htaccess,可以检查REFERRER。 This should match your domain (or a folder for that instance). 这应该与您的域(或该实例的文件夹)匹配。

RewriteEngine On
RewriteCond %{HTTP_REFERER} !mydomain\.com/page
RewriteRule ^ - [L,F]

You should add this in a new .htaccess of the folder you wish to protect. 您应该将其添加到要保护的文件夹的新.htaccess中。 Although, this is not foolproof. 虽然,这并非万无一失。 REFERRERS can be spoofed. 推荐人可以被欺骗。

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

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