Htaccess - 403状态码时,执行PHP文件


Htaccess - 403 status code when executing PHP file

我在C:/xampp/htdocs/下创建了一个名为synchro的目录我已经添加了一个PHP脚本test.php,其中包含一个web服务,我已经生成了一个密码文件。

和安全的文件夹,我添加了.htaccess文件,其中包含:

Options +Indexes
AuthUserFile "C:/xampp/htdocs/synchro/passwords"
AuthName "Authentication required"
AuthType Basic
Require valid-user 

但是当我尝试执行PHP文件

localhost/synchro/test.php

输入登录名和密码后得到Error 403我该怎么修理它?

您需要删除AuthUserFile周围的语音标记。它应该看起来像这样:

AuthUserFile /xampp/htdocs/synchro/passwords

然后需要一个名为.htpasswd的文件。这将是您创建登录名和密码的地方。

例如:

Admin:gl0IiOirI2n6M

所以你的AuthUserFile看起来像这样:

AuthUserFile /xampp/htdocs/synchro/.htpasswd