在json中创建Apache2服务目录索引

时间:2022-04-26 07:28:07

When enabled and privileged, the mod_dir module in Apache2 automatically serves a HTML formatted page with the contents of a directory when a directory is requested which does not contain an index.html file. I am looking for an easy way to make these directory contents machine readable; Preferebly have the contents of the directory formatted as a JSON array containing the subdirs/subfiles instead of an HTML page.

启用并具有特权时,Apache2中的mod_dir模块会在请求不包含index.html文件的目录时自动为HTML格式的页面提供目录内容。我正在寻找一种简单的方法来使这些目录内容机器可读;优选地将目录的内容格式化为包含子目录/子文件而不是HTML页面的JSON数组。

What would be a an easy way to accomplish this, that works on most standard configurations of Apache2.2? (no php scripts please)

什么是一个简单的方法来实现这一点,适用于Apache2.2的大多数标准配置? (请不要php脚本)

1 个解决方案

#1


1  

What would be a an easy way to accomplish this, what would work on most standard configurations of Apache2.2?

什么是一个简单的方法来实现这一点,什么将适用于Apache2.2的大多数标准配置?

There isn't one. You'd need to either modify and rebuild mod_autoindex, or you'd need to redirect to a script or generated JSON file on the server.

没有一个。您需要修改和重建mod_autoindex,或者您需要重定向到服务器上的脚本或生成的JSON文件。

#1


1  

What would be a an easy way to accomplish this, what would work on most standard configurations of Apache2.2?

什么是一个简单的方法来实现这一点,什么将适用于Apache2.2的大多数标准配置?

There isn't one. You'd need to either modify and rebuild mod_autoindex, or you'd need to redirect to a script or generated JSON file on the server.

没有一个。您需要修改和重建mod_autoindex,或者您需要重定向到服务器上的脚本或生成的JSON文件。