[英]PHP - Deny folder access without direct link to file?
I am creating a file hosting website. 我正在创建一个文件托管网站。 I would not like people to access the directory
我不希望人们访问该目录
public_html/quick/files
unless they have a direct download link from uploading a file. 除非他们有上传文件的直接下载链接。 How would I go about this?
我该怎么做?
For others: To rephrase, deny permission to index all the files. 对于其他人:改写,拒绝索引所有文件的权限。
使用以下内容在public_html
文件夹中创建名为.htaccess
的文件:
Options -Indexes
Creates a blank index.html file in the directories. 在目录中创建一个空白的index.html文件。
If thought necessary, create a redirect to an error page. 如果认为有必要,请创建重定向到错误页面。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;url=<URL_ERROR_PAGE>"></HEAD>
<BODY>
Optional page text here.
</BODY>
</HTML>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.