gpt4 book ai didi

php - 如何列出目录内容

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:03:59 25 4
gpt4 key购买 nike

没有索引文件时如何访问目录文件。

我使用了这个 htaccess 代码,但当我提到文件时它起作用了,但我想显示目录文件而不插入索引文件。

请检查我的htaccess代码并告诉我哪里错了谢谢

    RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ check.html?url=$1 [QSA,L]

最佳答案

您可以使用Options 配置选项。文档通过说

来呈现 选项

Configures what features are available in a particular directory

您可以使用许多选项,您正在寻找的选项是Indexes。要添加此选项,您需要指令 Options +Indexes

在 .htaccess 文件中,您只需将其放入即可使用它。

# Allows Apache to list the directory content
Options +Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ check.html?url=$1 [QSA,L]

在虚拟主机文件中它可能是这样的。

<Directory /var/www/html/mysite>
Options +Indexes
</Directory>

不过我建议在您的 vhost 文件中使用它。

As said in comment it's recommanded to configure a site in a vhost file. If you can (if your host allows you), use the vhost instead of the .htaccess file. If you can set all your configuration in your vhost and avoid using .htaccess, you can use AllowOverride None to forbid the .htaccess usage then.

参见 wikidocumentation .

关于php - 如何列出目录内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51673297/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com