Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess 500 error after login with AuthType Basic

Here's my .htaccess file:

AuthType Basic
AuthName "LOG IN"
AuthUserFile .htpasswd
Require valid-user

After logging in, I get a 500 error. If I clear the .htaccess file, it works fine.

Any ideas?

like image 894
Jake Avatar asked May 29 '13 07:05

Jake


2 Answers

I think you have to write the full path to your .htpasswd (on linux: /path/to/.htpasswd)

From http://weavervsworld.com/docs/other/passprotect.html

Troubleshooting

Make sure that the path specified in AuthUserFile is the correct full path. This is a major cause of problems. If Apache cannot find the .htpasswd file, then all attempts will fail.

Make sure the permissions on the .htaccess and .htpasswd files are set so that Apache can read them. chmod 0644 .htaccess chmod 0644 .htpasswd

Other issues may be out of your control. Web administrators can lock down Apache so that it ignores all .htaccess files it encounters. This can be achieved with an AllowOverride None directive and option on the ServerRoot/DocumentRoot directories. If this is the case (.htaccess not allowed) you will have to kindly ask your web administrator to allow .htaccess files with authorization directives in your personal web directory. This can be achieved with AllowOverride AuthConfig directive and option.

like image 66
steven Avatar answered Nov 13 '22 08:11

steven


Important : Full path to .htpasswd refers to the real full path if you are using terminal than use

maddy@maddy:/var/www/html/project_name$ pwd
/var/www/html/project_name

File In /var/www/html/project_name/.htaccess

AuthType Basic
AuthName "My restricted Area"
AuthUserFile /var/www/html/project_name/.htpasswd
Require valid-user

File In /var/www/html/project_name/.htpasswd

someuser:$apr1$oi0zg2sf$jTagKK2S7StjC0WSVJLUH0

To generate user: password combination refer

1) http://www.htaccesstools.com/htpasswd-generator/
2) https://www.web2generators.com/apache-tools/htpasswd-generator

Not tested

https://www.gaslampmedia.com/generate-htaccess-password-htpasswd-from-the-command-line/

like image 39
inrsaurabh Avatar answered Nov 13 '22 08:11

inrsaurabh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!