简体   繁体   English

关闭浏览器上的目录列表

[英]Close Directory Listing on Browser

I want to close one of my directories public access on my PHP server but at the same time same directory should be still accessible, so what I want to do is when user types that directory from browser like stackoverflow.com/directory they will see it closed/empty but when they want to access a file under that directory like stackoverflow.com/directory/file.php they will be able read and submit form on it. 我想在我的PHP服务器上关闭我的目录的公共访问权限,但同时仍然可以访问同一目录,所以我要做的是当用户从浏览器中键入该目录(例如stackoverflow.com/directory他们会看到它已关闭/为空,但是当他们想要访问该目录下的文件(例如stackoverflow.com/directory/file.php他们将能够读取并提交表格。 Any ideas how can I do this? 有什么想法我该怎么做?

Many thanks 非常感谢

Another method, using .htaccess file in the root 另一种方法,在根目录中使用.htaccess文件

Options -Indexes

Now if a folder does not have an index.html/php file the server will respond with a 404 file not found error and send people your error page. 现在,如果文件夹中没有index.html / php文件,则服务器将响应404文件未找到错误并向您发送错误页面。 Rather than a directory listing denied using the previous method. 而不是使用先前方法拒绝的目录列表。

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

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