简体   繁体   English

htaccess-执行PHP文件时的403状态代码

[英]Htaccess - 403 status code when executing PHP file

I have created a directory named synchro under C:/xampp/htdocs/ and I have added a PHP script test.php that contains a webservice and I have generated a passwords file. 我在C:/xampp/htdocs/下创建了一个名为sync的目录,并添加了一个包含Web服务的PHP脚本test.php ,并生成了一个密码文件。

And to secure the folder I have added .htaccess file that contains: 为了保护文件夹,我添加了.htaccess文件,其中包含:

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

But when I try to execute the PHP file 但是当我尝试执行PHP文件时

localhost/synchro/test.php

After entring login and password I got Error 403 How can I fix it? 输入登录名和密码后,出现Error 403如何解决?

You need to remove the speech marks from around AuthUserFile . 您需要从AuthUserFile周围删除语音标记。 It should look like this: 它看起来应该像这样:

AuthUserFile /xampp/htdocs/synchro/passwords

You then need a file called .htpasswd . 然后,您需要一个名为.htpasswd的文件。 This will be where you create your login and password. 这是您创建登录名和密码的地方。

For example: 例如:

Admin:gl0IiOirI2n6M

So your AuthUserFile will look like this: 因此您的AuthUserFile将如下所示:

AuthUserFile /xampp/htdocs/synchro/.htpasswd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM