Apache – 限制对所有文件夹的访问

我需要使用密码来限制对x个文件夹的访问,这是我的工作。

不过,我现在需要添加一个名为“公共”的文件夹,无需密码即可访问。 这需要与其他文件夹在同一水平。 我不能改变文件夹的布局,因为这会损害现有的链接。

OSX 10.4.11 Apache 1.3.41

这是我的configuration,到目前为止它将显示网站的根,而不需要密码,但它仍然要求公共文件夹的密码。 我不想使用.htaccess文件,但如果它是我唯一的select,我会。

<VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot "/Library/WebServer/example.com/www/" CustomLog "/var/log/httpd/access_log" "%h %l %u %t \"%r\" %>s %b" ErrorLog "/var/log/httpd/error_log" <Directory "/Library/WebServer/example.com/www/"> Options All +Indexes -ExecCGI +Includes +MultiViews AllowOverride None IndexOptions NameWidth=* Order Deny,Allow Allow from all </Directory> <Directory "/Library/WebServer/example.com/www/public/"> Options All +Indexes -ExecCGI +Includes +MultiViews AllowOverride None IndexOptions NameWidth=* Order Deny,Allow Allow from all </Directory> <Directory "/Library/WebServer/example.com/www/*/"> Options All +Indexes -ExecCGI +Includes +MultiViews AllowOverride None IndexOptions NameWidth=* AuthName "Restricted Area" AuthType Basic AuthUserFile /Library/WebServer/example.com/.htpasswd require valid-user </Directory> </VirtualHost> 

我意识到AuthType Basic的问题,也意识到运行一个非常旧版本的Apache的问题。

在您的号码 Directory指令的末尾添加满意的任何内容 :

 <Directory "/Library/WebServer/example.com/www/public/"> Options All +Indexes -ExecCGI +Includes +MultiViews AllowOverride None IndexOptions NameWidth=* Order Deny,Allow Allow from all Satisfy Any </Directory> 

客户端将被授予访问权限,而不会提示input密码。