简体   繁体   中英

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.

And to secure the folder I have added .htaccess file that contains:

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

localhost/synchro/test.php

After entring login and password I got Error 403 How can I fix it?

You need to remove the speech marks from around AuthUserFile . It should look like this:

AuthUserFile /xampp/htdocs/synchro/passwords

You then need a file called .htpasswd . This will be where you create your login and password.

For example:

Admin:gl0IiOirI2n6M

So your AuthUserFile will look like this:

AuthUserFile /xampp/htdocs/synchro/.htpasswd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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