【发布时间】:2017-04-02 05:10:56
【问题描述】:
我试图阻止对 apache 中特定文件夹的直接访问。
我的文件夹结构: /var/www/html - page.html - 私人文件夹 -CSS -jss
我正在尝试使用密码保护私人文件夹。
我完成了以下步骤:
1 .在私人文件夹中创建一个 .htacess 文件。
.htacess 文件:
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
2 。在 /etc/apache2 中使用 htpasswd 创建一个 .htpasswd 文件
- 现在我更改了 /etc/apache2/apache2.conf 中的一些规则。
但是当我访问 10.0.0.1/private 时,我可以在没有密码的情况下浏览这个目录。
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
</Directory>
<Directory /var/www/>
Options All
</Directory>
AccessFileName .htaccess
还有什么问题吗?我为.htaccess 和.htpasswd 设置了写权限
sudo chmod 777 /var/www/html/private/.htaccess
和
sudo chmod 777 /etc/apache2/.htaccess
有什么建议吗?
【问题讨论】: