error 500 on xampp using htacces (Password) - apache

Hi I am getting error 500 on Apache webserver using xampp. The error wasnt there until i used a .htaccess, .htpasswd file. I searched and i couldnt find a syntax error. I have only 1 image and the index file I want to protect. Here are the syntaxes:
.htaccess
AuthType Basic
AuthName "Prosím přihlašte se.";
AuthUserFile C:\xampp\htdocs\Zprávy 1.E\.htpasswd
require valid-user
.htpasswd
zak:$apr1$t8hZiqXE$0qdoQ/876dOqysUmww2NM/

You have syntax error on your .htaccess file, you should quote the file path because it has space between.
AuthType Basic
AuthName "Prosím přihlašte se.";
AuthUserFile "C:\xampp\htdocs\Zprávy 1.E\.htpasswd"
require valid-user

Related

Protect only a directory with htpasswd

I would like to protect the protect-me-dir directory with http password. I tried this code:
AuthType Basic
AuthName "restricted area"
AuthUserFile /home/iterator/public_html/protect-me-dir/.htpasswd
require valid-user
It works, but unfortunately it asks for the password everywhere, not just in protect-me-dir. How is it possible to protect only that directory?
If I put this code inside <Directory "/home/iterator/public_html/protect-me-dir">...</Directory>, I get Internal Server Error
Just put the .htaccess file in the directory you want to password-protect. It is a per-directory config file.

Apache "Require valid-user" does not work

I am writing a htaccess file for Apache 2.4.
I have in the basic config the directives "AllowOverrideAll" and "Require all granted" and I want to restrict the access to a folder.
Then I create a .htaccess file in the folder.
The file works if I set for example "Require all denied", but if I set "Require valid-user" I have a misconfiguration error.
For example, if I try the htaccess with this content
AuthType Basic
AuthName "Authentication Required"
Authuserfile "/etc/htpasswd/.htpasswd"
require all denied
works ("Forbidden: You don't have permission to access /TorGuard/ on this server.")
but with this content
AuthType Basic
AuthName "Authentication Required"
AuthUserfile "/etc/htpasswd/.htpasswd"
require valid-user
I have an error ("Internal Server Error: The server encountered an internal error or misconfiguration and was unable to complete your request.")
In particular I am working on a QNAP and the htaccess is in the folder of the WEBUI of my application.

htaccess adding password while enabling directories view in browser

Okay this might be a very obvious one however...
I have the following in my .htaccess file
AuthType Basic
AuthName "Message"
AuthUserFile /www/sites/5ce/448/domainname/folder.htpasswd
require valid-user
Which works fine for password protecting the folder it's placed in.
I also have in another .htaccess file (when I remove the first one)
Options +indexes
Which works fine for showing the directory folder and included files on browser.
When I put these together i get Error 500. How do you essentially enable directory view but password protected?
There shouldn't be a space between the + and the indexes.
Try this:
AuthType Basic
AuthName "Message"
AuthUserFile /www/sites/5ce/448/domainname/folder.htpasswd
require valid-user
Options +Indexes

.htaccess doesn't ask me for password

I'm trying to protect a directory adding a .htaccess and a .htpasswd but instead asking me for password, it goes to the home page of my site directly.
My .htaccess is being read (put some garbage in it and I got 500 error).
Here's my .htaccess :
AuthName "Page d'administration protégée"
AuthType Basic
AuthUserFile "/Applications/MAMP/htdocs/backoffice_mollanger/app/.htpasswd"
Require valid-user
And my .htpasswd
Admin:gl0IiOirI2n6M
First of all, remove the speech marks you have around the .htpasswd location, they should not be there. If that does not help then try using this, you can specify the directory you want to protect by stating the file name in replace of example:
<Files /example>
AuthName "Page d'administration protégée"
AuthType Basic
AuthUserFile /Applications/MAMP/htdocs/backoffice_mollanger/app/.htpasswd
Require valid-user
</Files>

500 Error with .htaccess password protection

I am running latest ubuntu with apache.
I have very simple html directory I want to protect using .htaccess.
I am trying to do it with:
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/dev/docs/.htpasswd
Require valid-user
On my .htpasswd file I have:
user:pass
I get internal server error with this. I've been digging hard but not sure why this is happening.
If I add a this:
<Directory "/var/www/dev/docs">
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/dev/docs/.htpasswd
Require valid-user
</Directory>
I can't login no matter what I do...
Thanks,
I have the same problem. But after a few trial and error, here's the fix.
You must use the full path to the .htpasswd file.
You must encapsulate the path with quotation marks "home/username/public_html/subfolder/protected/.htpasswd"
An example:
AuthUserFile "/home/username/public_html/subfolder/protected/.htpasswd"
AuthType Basic
AuthName "My restricted Area"
Require valid-user
Error #500 just means the web server isn't understanding something in your .htaccess file. There will be nothing in Apache's error log since the request doesn't even get parsed at this point.
Try putting quotes around the path to the .htpasswd file and note on some hosting companies like cough.. godaddy, 1&1 It may take several minutes for the changes in .htaccess to be picked up.
AuthType Basic
AuthName "Restricted Area"
AuthUserFile "/home/. . . . ./.htpasswd"
require valid-user
I have got same situation on Apache/2.4.6 (CentOS)
Path to htpasswd needs to be taken from $_SERVER['DOCUMENT_ROOT']
Apache has some bug (https://bz.apache.org/bugzilla/show_bug.cgi?id=54735), you need to set password from console like this:
htpasswd -nb username newpassw > <path-to>/.htpasswd
btw in Apache 2.4.6 on CentOS 7 problem still exists