我正在尝试在 apache2 中对访问我的文档根目录进行身份验证...
这是我的配置文件
<VirtualHost *:80>
ServerAdmin webmaster@localhost
AccessFileName .htaccess
DocumentRoot /home/user/workspace
<Directory />
Options FollowSymLinks
AllowOverride None.htaccess
</Directory>
<Directory /home/vishu/workspace>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
</Directory>
......
......
</VirtualHost>
这是我在/home/user/workspace 文件夹中的 .htaccess 文件:
<FilesMatch >
.....
</FilesMatch>
AuthType Basic
AuthName "MY ZONE"
#AuthBasicProvider file
AuthUserFile /home/vishu/workspace/passwordfile
AuthGroupFile /dev/null
Require valid-user
.....
...
Apache 给
.htaccess:order not allowed here
错误,我从浏览器收到 500 错误。
最佳答案
看看你的 AllowOverride
指令。我也有这个问题,但以下配置对我有用:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride AuthConfig Limit
Require all granted
</Directory>
AllowOverride All
也可能会起作用,这取决于您要允许多少。查看这两个链接以获取更多信息:
https://drupal.org/node/10133
http://httpd.apache.org/docs/2.2/howto/auth.html
关于.htaccess:此处不允许订购,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14250674/