.htaccess with .htpasswd always 500 internal server error - php

My htaccess is giving some problems.
AuthType Basic
AuthName "Please Log In"
AuthUserFile ./lib/.htpasswd
Require valid-user
Order deny,allow
Deny from all
allow from xxx.xxx.xxx.xxx
Satisfy any
The ip whitelist works.
But the authentication doesnt work.
When i give some data to the login page it returns 500 internal server error
I tried lots of things and couldn't fix it
My htpasswd:
user:fv6WWK8ZYdGtU

Related

Protecting /index.html with .htaccess file

I would like to use a .htaccess and a .htpasswd file to protect access to a website.
The following code successfully brings up the auth dialog when visiting mysite.com. But when visiting mysite.com/index.html the auth dialog does not appear and the website can be accessed without protection.
.htaccess
AuthUserFile /path/to/.htpasswd
AuthType Basic
AuthName "Password Protected"
Require valid-user
What do I need to change to ensure that mysite.com/index.html is protected as well?
I have tried adding:
Order Deny,Allow
Deny from all
Satisfy any
Require valid-user
and also:
<Files "index.html">
Require valid-user
</Files>
Neither make any difference to the problem.
maybe you could try it with
AllowOverride AuthConfig
If I remember it right it is not activated on the default :)
you can get more information in the official apache doc
https://httpd.apache.org/docs/2.4/howto/auth.html

.htaccess requests correct login twice with .htpasswd and wordpress

I use .htaccess to ask for credentials to access members only data. The .htaccess file is stored in one of the directories and protects everything in directories below it. The .htaccess file itself is very simple:
AuthName "Members Area"
AuthType Basic
AuthUserFile /home/xxxxx/public_html/xxx/data/.htpasswd
require valid-user
Problem is, when we moved to a new server (and built the new website within that directory using WordPress), the Authentication Box now comes up twice and requires users to enter the same correct login information both times.
I've read in other strings here about trailing /, but since I don't have a redirect or anything else in my .htaccess, I'm not quite sure what to do.
Anybody have any suggestions on a workaround or rewrite?
This is most likely because you're running an https redirect (or another redirect) inside another .htaccess file. So it is asking for the authentication once in http, and once in https. If you do this:
<If "%{HTTPS} == 'on'">
AuthType Basic
AuthName "Password Area"
AuthUserFile "/yourdirectory/.htpasswd"
<IfVersion >= 2.4>
AuthMerging And
</IfVersion>
Require valid-user
</If>
then it will only ask for the password once the redirect has happened. Otherwise, get rid of the second redirect.

I'm trying to password protect my website and when i get the popup to login and i use my creds

I always get this error:
Internal Server Error
?The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#stage.mysite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a
500 Internal Server Error
error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.24 (Unix) mod_hive/4.0 mod_ssl/2.2.24 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at stage.mysite.com Port 80
Here's what I've done in the htaccess file:
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile "/home/feli33/public_html/.htpasswd"
Require valid-user
and in the root of the public html folder I have my .passwd file:
the only thing in it is a username and an md6 hash:
admin:li3fFizhXCgMU
Any help would be appreciated. Thank you.
This is how my .htaccess looks like. I've created my .htpasswd file by running htpasswd -c .htpasswd username. The password is pass.
AuthType basic
AuthName "private area"
AuthUserFile "/var/www/path/to/.htpasswd"
Require valid-user
Command to create .htpasswd file.
htpasswd -c .htpasswd username
.htpasswd file.
username:$apr1$QC6hD31s$I/uGkzaIrnUp/5sSURRH00

500 error when .htaccess authetication added

A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again.
This error is displayed only after I add this authentication part to my .htaccess...If I remove this part it shows the admin area without authentication....Please can anyone point out whether there is any syntax error...
<FilesMatch "admin">
AuthUserFile "/home6/zeewatch/public_html/ecole-de-paris-fr//httpd.www/mu/.htpasswd
AuthGroupFile /dev/null
AuthName "admin"
AuthType Basic
Require valid-user
</FilesMatch>
Try this
<FilesMatch "admin">
AuthName "Admin Panel"
AuthType Basic
AuthUserFile /path/.htpasswd
Require valid-user
</FilesMatch>
and what this?
ecole-de-paris-fr//httpd.www/mu/.htpasswd
you have "//" on the path, make it one forward slash

htaccess Internal server error, authentication loop

I am attempting to set up htaccess to restrict access to a particular folder. I currently have as follows:
Htaccess:
AuthType Basic
AuthName "Restricted area"
AuthUserFile /home3/user/public_html/.htpasswd
require valid-user
ErrorDocument 404 "Error"
ErrorDocument 401 "Error"
ErrorDocument 403 "Error"
htpasswd:
Guest:GuestPassword
Using this method I will either have a 500 server error returned, OR it will loop and continuously prompt me for authentication.
Any help is appreciated!
ALSO: I used showphp() to get the Document root. So AuthUserFile path should be correct.
Thanks!
The infinite loop asking for your password is what you want to see. That means you typed in your password wrong. The Internal Server 500 Error means you have another issue in your code. The reason your username and password aren't working is because your server expects the password to be hashed.
Change your .htpasswd file to:
Guest:$apr1$u5E5vgOR$6rPNEYkeaF5IVE4c3FyKM0
(The password is GuestPassword)

Categories