大网数据广告活动
网站运营与故障问答

how to display directory structure in public_html?

· 52CE 我爱测

I just set up apache and was able to get a site running. I want to use user directories in /home/*/public_html to display some data so a collaborator can download stuff I put on the user directory. I uncomment the http-userdir.co…

问题原文

原帖链接 · olala · CC BY-SA 3.0

I just set up apache and was able to get a site running. I want to use user directories in /home/*/public_html to display some data so a collaborator can download stuff I put on the user directory.

I uncomment the http-userdir.conf part in the main httpd.conf file and it was working. However, I can only see the contents of a file in the user directory instead of seeing the list of files. i.e. if I have a file called file.txt that has 'hello world' in it and it's path is /site_url/data/file.txt. when I put this whole path on a web browser, I can see 'hello world'. But when I use /site_url/data, it says "The requested URL /site_url/data/ was not found on this server." The permission for everything under public_html is 755.

Here is the http-userdir.conf file.

 10 UserDir public_html
 11
 12 #
 13 # Control access to UserDir directories.  The following is an example
 14 # for a site where these directories are restricted to read-only.
 15 #
 16 <Directory "/home/*/public_html">
 17     AllowOverride FileInfo AuthConfig Limit Indexes
 18     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
 19     Require method GET POST OPTIONS
 20 </Directory>

Which option should I change to make it display files in directories under public_html?

Thanks!

已采纳解答

原帖链接 · olala · CC BY-SA 3.0

OK. I found an answer. I read from the apache doc:

https://wiki.apache.org/httpd/DirectoryListings

If no file from the DirectoryIndex directive can be located in the directory, then mod_autoindex can generate a listing of the directory contents. This is turned on and off using the Options directive.

So I uncomment the mod_autoindex load module line in httpd.conf and now the directory listing works.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。