[英]Laravel: Prevent direct access of files from public folder
I am stuck on this part of my laravel application, Where I am asked to protect the files from directly accessed via url browser hit. 我被困在laravel应用程序的这一部分中,要求我保护该文件以免通过URL浏览器直接访问。 I have a public folder in which in a doc folder is present where all the documents are going to be uploaded. 我有一个公用文件夹,其中有一个doc文件夹,所有文档都将被上传到该文件夹中。 I just need a solution to prevent this where i can access docs directly from my application but any third party visitor can not view my docs (images,pdfs etc..). 我只需要一个解决方案来防止这种情况,我可以直接从我的应用程序访问文档,但是任何第三方访问者都不能查看我的文档(图像,pdf等)。
I have tried many solutions but its not at all working. 我已经尝试了许多解决方案,但根本无法正常工作。 I just want to things :- 1. Protect my docs through direct access. 我只想了解以下内容:1.通过直接访问保护我的文档。 2. Way of implementing it in laravel (via .htaccess) 2.在laravel中实现它的方式(通过.htaccess)
I know this can be possible through htaccess, but how? 我知道这可以通过htaccess实现,但是怎么办? Kindly help Please :) 请帮助:)
There are three approaches I can think of just now; 我现在可以想到三种方法:
在您的上传文件夹.htaccess
文件中添加以下内容:
Deny from all
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.