0

I want to secure by basic http authentication my dev site in Laravel with .htaccess and .htpasswd.

First, I created my .htpasswd user and password (https://shop.alterlinks.com/htpasswd/htpasswd.php MD5). Then, my htaccess file with some basic configurations.

I placed my .htaccess file on my project directory /home/user/public_html/laravel_project. Then .htpasswd file in /home/user/htpasswd/.htpasswd.

Also in my apache configuration file, I have AllowOverride All

.htaccess code:

AuthType Basic
AuthName "Site Administratrion"
AuthBasicProvider file
AuthUserFile "/home/user/htpasswd/.htpasswd"
Require user admin

After all those configurations, I cleared my cache and tested. At first asks normally for credentials, the login page of my site loads but after i login asks again for htpasswd credentials and throws an ERROR 401 Unauthorized

Error:

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

By the way, I don't have apache logs on this problem.

Is it Laravel/React related? I need aditional configurations? I think i've tried almost anything.

  • What are the permissions of /home/user/htpasswd/.htpasswd ? Make sure it's readable by the apache process – Capsule Aug 12 '19 at 02:41
  • Yes, it has **W**, **R** and **X** permissions for my user, group and others, still not working. – francisco cueva Aug 12 '19 at 03:54
  • Try to move it temporarily to public_html and modify the path in htaccess and see if it works. The issue might be on a `htpasswd` folder level. – Capsule Aug 12 '19 at 04:11
  • Thank you for the suggestion, but still throws Error 401. Why asks for password when i try to login. Shouldn't be enough when i open the application on the browser? – francisco cueva Aug 12 '19 at 05:53
  • Cross-site post on Webmasters: https://webmasters.stackexchange.com/questions/124544/how-to-fix-htaccess-error-keeps-asking-for-authentication – MrWhite Aug 13 '19 at 23:15

0 Answers0