简体   繁体   中英

how to Folter password protection using .htaccess and .htpasswd?

This my path: http://172.21.4.100/bluescope_app/index.php?page=creer_contact_client

I have two files:

1 st : .htpasswd holds only:

dave: ***password***

2 nd : .htaccess holds:

AuthType Basic
AuthUserFile /172.21.4.100/bluescope_app/dave/.htpasswd  //<---- I'm stuck here, is this correct ?

AuthName "Enter valid username and password!"

<Files test.php>
    require valid-user
</Files>

On browser I got prompt but I can't access with my password.

If you know the answer Post as much as possible, thank you.

Included path:

http://172.21.4.100/bluescope_app/.htaccess

http://172.21.4.100/bluescope_app/.htpasswd

AuthUserFile should include the absolute path not URL

To get the absolute path, you can do this in php :

echo $_SERVER['DOCUMENT_ROOT']; 

It will return something like

/home/user98/www/public_html/

So in that case, since your .htpasswd is in the directory bluescope_app/dave

You should do :

AuthUserFile /home/user98/www/public_html/bluescope_app/dave/.htpasswd

This in an example on linux, if you are on windows it will be almost the same...

I got answer , I used Double Quotes then i got ,,

AuthUserFile "/var/www/html/bluescope_app/dave/.htpasswd"

thanks for your idea (use absolute path)@Dany Khalife

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