htaccess的不允许用户查看我的文件夹的文件不具有的index.php我的、有的、不允许、文件夹

2023-09-02 09:43:56 作者:對著太陽說,日

在我的服务器,我已经创建了一个不具有的index.php或index.html文件夹。

On my server, I've created a folder that doesn't have an index.php or index.html.

folder1/test.php
folder1/sample.php
folder1/hello.php

当我试图访问该文件夹,它显示了在那里的所有文件。

When I tried to visit that folder, it shows all the files in there.

这是我关心的,它不应该显示的文件在我的文件夹,因为很容易出现的黑客攻击。它应该显示一个网页像403禁止。我不想使用的index.php文件只是他们重定向到某个地方。

That is my concern, it should not show the files in my folder because it is prone to hacking. It should display a page like a 403 Forbidden. I don't want to used an index.php just to redirect them to somewhere.

我听说,这涉及到的.htaccess,这是一个聪明的做法。

I heard that this involves .htaccess and this is a smart thing to do.

请教我该怎么做。

推荐答案

在您的文档根目录的的.htaccess 文件...

In a .htaccess file in your document root...

Options -Indexes

请参阅 http://httpd.apache.org/docs/2.2 /mod/core.html#options