目录列表中缺少带有 .htpasswd 的目录

Directory with .htpasswd is missing in directory listing

父目录中有多个目录,如果我将 .htaccess(见下文)添加到子目录,则该目录将不再列在父目录列表中。

    AuthType Basic
    AuthName "restricted area"
    AuthUserFile /home/www/example.cz/www/dokumentace/file/.htpasswd
    require valid-user

这能以某种方式改变吗?谢谢!

默认情况下,目录列表隐藏了 return 403 Forbidden:

When a directory listing is produced, certain files will not be shown, by default. Files and directories that have access restrictions placed on them, either by password or by address, will not be shown in a directory listing.

If you want these files to be listed, you will need to set IndexOptions ShowForbidden in the directory block in question. The ShowForbidden setting is only available in 2.2 and later.

Source: Apache Wiki

总而言之,如果您确定要显示它们,您应该将以下内容添加到您的配置中(全局或在父目录的 .htaccess 中):

IndexOptions ShowForbidden