使用 htaccess 和基于 IP 的 Apache 2.4 mod_authz_host 启用索引(文件夹视图)
Enabling Indexes (folder views) using htaccess with Apache 2.4 mod_authz_host based on IP
需要通过基于 IP 的 htaccess 在 apache 2.4 中启用索引。
例如,IP 192。168.x.x
我尝试将指令放入 apache2.conf 文件中,例如:
<Directory /var/vhosts/lubrigard.com>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
然后
<Directory /var/vhosts/lubrigard.com>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require ip 192.168
</Directory>
然而,对于任何其他 IP,它拒绝对该文件夹的任何访问。
所以我禁用了站点范围内的索引,并想放置一个 .htaccess 文件来为内部 IP 地址启用索引。除非有人能告诉我如何在 apache2.conf 文件中进行操作。
这有效,它显示 "Forbidden, You don't have permission to access /folder/ on this server." 而不是 "Directory listings denied." 我仍然可以访问该文件夹中的文件。
<If "%{REMOTE_ADDR} == '192.169.0.95'">
Options +Indexes +FollowSymLinks +MultiViews
Require all granted
</If>
<Else>
Options -Indexes +FollowSymLinks +MultiViews
Require all granted
</Else>
我也试过:
<If "%{REMOTE_ADDR} == '192.169.0.95'">
Options +Indexes
</If>
<Else>
Options -Indexes
</Else>
两者都有效。我唯一的问题是我不想指定完整的 IP。我宁愿它使用 IP 的前 3 个字节:192.168.0.xxx
出于某种原因,如果未启用索引,则用户无法访问此文件夹中的内容。我只是想禁用目录列表,而不是阻止对该文件夹中文件的访问。
谢谢!这就是我一直在寻找的东西并且它有效。
关于你的问题...
Both have worked. My only issue is that I didn't want to specify the full IP. I would have rather it use the first 3 bytes of the IP: 192.168.0.xxx
试试这个:<If "-R '192.168.0.0/24'">
需要通过基于 IP 的 htaccess 在 apache 2.4 中启用索引。
例如,IP 192。168.x.x
我尝试将指令放入 apache2.conf 文件中,例如:
<Directory /var/vhosts/lubrigard.com>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
然后
<Directory /var/vhosts/lubrigard.com>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require ip 192.168
</Directory>
然而,对于任何其他 IP,它拒绝对该文件夹的任何访问。
所以我禁用了站点范围内的索引,并想放置一个 .htaccess 文件来为内部 IP 地址启用索引。除非有人能告诉我如何在 apache2.conf 文件中进行操作。
这有效,它显示 "Forbidden, You don't have permission to access /folder/ on this server." 而不是 "Directory listings denied." 我仍然可以访问该文件夹中的文件。
<If "%{REMOTE_ADDR} == '192.169.0.95'">
Options +Indexes +FollowSymLinks +MultiViews
Require all granted
</If>
<Else>
Options -Indexes +FollowSymLinks +MultiViews
Require all granted
</Else>
我也试过:
<If "%{REMOTE_ADDR} == '192.169.0.95'">
Options +Indexes
</If>
<Else>
Options -Indexes
</Else>
两者都有效。我唯一的问题是我不想指定完整的 IP。我宁愿它使用 IP 的前 3 个字节:192.168.0.xxx
出于某种原因,如果未启用索引,则用户无法访问此文件夹中的内容。我只是想禁用目录列表,而不是阻止对该文件夹中文件的访问。
谢谢!这就是我一直在寻找的东西并且它有效。
关于你的问题...
Both have worked. My only issue is that I didn't want to specify the full IP. I would have rather it use the first 3 bytes of the IP: 192.168.0.xxx
试试这个:<If "-R '192.168.0.0/24'">