如何让 apache 列出文件夹内容?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1214887/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:00:25  来源:igfitidea点击:

How can I get apache to list a folders contents?

apachedirectory

提问by samoz

How can I get Apache to display the contents of my folder and provide links to them? Similar to http://www.kernel.org/pub/linux/?

如何让 Apache 显示我的文件夹的内容并提供指向它们的链接?类似于http://www.kernel.org/pub/linux/

I don't have access to the Apache configuration, so I'm looking for something in the way of .htaccess or something I can do in just my home folder.

我无权访问 Apache 配置,所以我正在寻找 .htaccess 或我可以在我的主文件夹中做的东西。

回答by Pascal MARTIN

You have to use the option Indexes in the Apache configuration.

您必须在 Apache 配置中使用选项索引。

For instance, in the .htaccess file for your directory (if you can use those, and have sufficient privilegies), you could put :

例如,在您目录的 .htaccess 文件中(如果您可以使用这些文件,并且有足够的权限),您可以放置​​:

Options +Indexes

This functionnality is provided by mod_autoindex, which has lots of options to allow fine-tunning of the generated output, btw

此功能由 提供mod_autoindex,它有很多选项可以微调生成的输出,顺便说一句

To get this working, that module must be loaded, and to be able to activate the option in an .htaccess file, you will need the admin of the server to give you some privilegies (with the AllowOverridedirective in the Apache's main config file, if I remember correctly -- well, your admin should know that better than me anyway ^^ )

要使其正常工作,必须加载该模块,并且能够激活 .htaccess 文件中的选项,您将需要服务器管理员为您提供一些特权(使用AllowOverrideApache 的主配置文件中的指令,如果我没记错——好吧,无论如何,你的管理员应该比我更了解这一点^^)