File authentication htaccess


#1

I am having difficulties in solving authentication for a specific HTML file.

I have tried using the Dreamhost config:

#Protect file

AuthName "#protectfile"
AuthType Basic
AuthUserFile /home.net/bio/me/.htpasswd
Require valid-user

I have created an encrypted pw inside .htpasswd and that file is living inside /home.net/bio/me/.htpasswd

The file I am trying to ask for authentication u/pw lives inside /home.net/bio/me/me.html

With the Dreamhost suggestion, I do not see how I am calling for that specific HTML file inside that folder, if I am only coding

This did not work.

Then I tried the same .htpasswd and create a .htaccess file from scratch with this code:

#Protect file
AuthType Basic
AuthName "#protectfile"
AuthUserFile /home.net/bio/me/.htpasswd
AuthGroupFile /dev/null
Require valid-user
SetEnvIf Request_URI “(/home.net/bio/me/me.html)$” allow
Order allow,deny
Allow from env=allow
Satisfy any

But it did not work either. So I was trying to see if it was a permissions issue, as the dialogue box sometimes pops up, but once one insert the correct u+pw, it launches a a 500 Internal Server Error page. I tried permissions 0644 for .htaccess and 0640 for .htpasswd and the folder /home.net/bio/me as it is a directory-type with 0711. It did not work even with other permission codes.

Inside this folder lives a txt and png file, that I want to give the public access after they authenticate themselves at /home.net/bio/me/me.html. This page, me.html as 2 hyperlinks for those files.

Could someone give me a hand here, please? That would be much appreciated.

Cheers,


#2

This is how I do it:
Example:
Protected Directory: yourdirectory
.htaccess located at /home/user/domain/yourdirectory
.htpasswd located somewhere in the protected directory: /home/user/domain/yourdirectory/bin/

AuthType Basic
AuthUserFile /home/user/domain/yourdirectory/bin/.htpasswd
AuthName "Whatever Title You Want To Give"
require valid-user

EDIT - My bad, for single file protection use this in your .htaccess

AuthUserFile /home/user/domain/yourdirectory/bin/.htpasswd
AuthName "Whatever Title You Want To Give"
AuthType basic
<files /home/user/domain/yourdirectory/yourprotectedfile.html>
require valid-user


#3

thanks @legacy

so now i just got this:

#Protect
AuthName "protect"
AuthType Basic
AuthUserFile /home/user/domain.net/dir/subdir/.htpasswd
<files /home/user/domain.net/works/dir/subdir/page.html>
Require valid-user
AuthGroupFile /dev/null

Is there any error in the syntax? Now the page loads but no dialogue box asking username and pw appears, so the HTML file is not protected, but it loads.

I went along and enabled afterwards the dreamhost goodie Htaccess/WebDAV and protected the subdirectory as well, because i actually would like users, who will be sharing the same username, to perhaps write (+read) and upload files to that directory, if possible with the WebDav, though not sure how to ask them to due it.