0

通过键入http://www.mywebsite.com/myfile可以通过我的网站访问一个文件,并且服务器在 debian 上运行。

我想在尝试访问以前的 url 时使用 .htaccess 和 .htpasswd 进行身份验证。

我对 .htaccess 很陌生,我尝试使用文档对其进行配置,但它似乎不起作用,因为当我尝试没有任何更改并且当我检查错误日志时,我得到了:

[错误] [客户端 IP] 客户端被服务器配置拒绝:/home/file1/myfile/www/.htaccess

我的 .htaccess 的内容是:

<Directory /home/file1/myfile/www/>
    AuthUserFile /home/file1/myfile/.htpasswd
    AuthGroupFile /dev/null
    AuthName "My authentication"
    AuthType Basic
    Require valid-user

    Otions Indexes FollowSymLinks Multiviews
    AllowOverride All
    Order allow,deny
    allow from all

    Redirect permanent /.htaccess http://www.mywebsite.com/myfile
    ServerSignature Off
</Directory>

请问我该如何解决这个问题?

4

2 回答 2

0

似乎删除 et 再次创建用户足以解决 FTP 连接问题。

我已经使用以下内容修改了我的全局 apache 配置:

DirectoryIndex index.html index.htm index.xhtml index.php index.txt

ServerName debian.domain.tld
#ServerName localhost
HostnameLookups Off

ServerAdmin myadressemail

UserDir www
UserDir disable root

<Directory />
    Options -Indexes FollowSymLinks
    AllowOverride All
</Directory>

ServerSignature Off

现在我的 .htaccess 是:

AuthUserFile /home/file1/myfile/.htpasswd
AuthGroupFile /dev/null
AuthName "My authentification"
AuthType Basic
Require user user1

但是我仍然没有询问身份验证,我做错了什么?

于 2013-08-09T12:54:05.260 回答
0

您不能<Directory>在 htaccess 文件中使用容器。删除它们,以便您拥有:

AuthUserFile /home/file1/myfile/.htpasswd
AuthGroupFile /dev/null
AuthName "My authentication"
AuthType Basic
Require valid-user

Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order deny,allow
deny from all

Redirect permanent /.htaccess http://www.mywebsite.com/myfile
ServerSignature Off

(你Otions拼错了)

此外,通过查看您的错误,您似乎正在尝试直接访问 htaccess 文件,而不是myfile. 服务器上可能有额外的配置来拒绝访问 htaccess 文件(或所有以 a 开头的文件.)。

于 2013-08-08T08:02:50.473 回答