我有一个具有类似配置的虚拟主机。
当我尝试进入 foobar.com/dir 并提供有效的用户名/密码对时,我得到的是 403 禁止页面而不是该目录的内容。
www.foobar.com/dir 具有 777 权限,.httpaswd 的权限为 644。但我不明白为什么我仍然看不到内容。请给我一点提示。
ServerAdmin webmaster@localhost
ServerName www.foobar.com
ServerAlias www.foobar.com
DocumentRoot /var/www/foobar
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/foobar>
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/foobar/dir>
AllowOverride AuthConfig
AuthName "Authorize yourself, please!"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
AuthGroupFile /dev/null
Allow from All
Order Allow,Deny
Options +Indexes<<- that one should be added
Require valid-user
答案1
添加Options +Indexes
最后一条<Directory>
语句