使用 Apache2,我如何要求每个页面都有一个有效的用户除了这些特殊的页面是任何人都可以看到的吗?
提前感谢您的想法。
更新为了回应评论;这是一个有效的 apache2 配置:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
allow from all
</Directory>
# require authentication for everything not specificly excepted
<Location / >
AuthType Basic
AuthName "whatever"
AuthUserFile /etc/apache2/htpasswd
Require valid-user
AllowOverride all
</Location>
# allow standard apache icons to be used without auth (e.g. MultiViews)
<Location /icons>
allow from all
Satisfy Any
</Location>
# anyone can see pages in this tree
<Location /special_public_pages>
allow from all
Satisfy Any
</Location>
答案1
这应该可以解决问题:
<Location / >
AuthType Basic
AuthName "whatever"
AuthUserFile /etc/apache2/htpasswd
Require valid-user
AllowOverride all
</Location>
<Location /yourspecial>
allow from all
Satisfy Any
</Location>
满足任意是至关重要的一个。