cancel
Showing results for 
Search instead for 
Did you mean: 

htpassword

Julie
Grafter
Posts: 791
Registered: 28-07-2007

htpassword

Please can someone help me, I have been trying to password protect a download on my site with an .htpassword file and it is not working.

I have searched the site, and no matter what I do I am still getting the download come up ...I cannot even get a login box.

The zip file is in its own sub directory directly in htdocs...I would be really grateful for some help please.

Many thanks
Julie
19 REPLIES
Community Veteran
Posts: 14,469
Registered: 30-07-2007

htpassword

Do a search on this message board for .htpasswd there are lots of threads explaining how to do it.

Cheers

Peter Cool
Julie
Grafter
Posts: 791
Registered: 28-07-2007

htpassword

Thanks for your reply, much appreciated
I have done that, and sorry for being dumb Shockedops:

But it's not working what am I doing wrong?? I have never done an htaccess file before, and I am tring to help someone out by linking this file and they want it password protected Cry

Cheers for any advice...is it the path, do you have to put the full path to the file?Huh
N/A

htpassword

Have a look at this htaccess tutorial - it covers using htpasswd.
Julie
Grafter
Posts: 791
Registered: 28-07-2007

htpassword

Thanks...I have followed the tutorial...I am obviously doing something wrong...sorry for posting back again but its not working, please can someone help me

I am saving the file as .htpasswrd

copying the code and changing the path...but everything I try is not working Cry

many thanks
Julie
michaelscott
Grafter
Posts: 594
Registered: 09-08-2007

htpassword

u also need an .htaccess file in the directory u are trying to protect.
Community Veteran
Posts: 14,469
Registered: 30-07-2007

htpassword

Quote
I am saving the file as .htpasswrd


Are you sure that is what you called it in the .htaccess file - the normal name is .htpasswd (no r) although if that is what you called it in .htaccess it should be OK.

I think we need to see what you have put in .htaccess and .htpasswd (just remove any names you don't want us to know about but use another example in it's place).

Also have you put the actual password in as a unix encrypted string rather than the actual password in plain text?

Also explain what you are trying to password protect.
Julie
Grafter
Posts: 791
Registered: 28-07-2007

htpassword

Hello

Thanks so much for your replies, I have tried so many things now, and I tried also putting an htaccess file in but I got 'server error' when I tried the link.

What I am trying to do is give users to my site a direct link to a file which is in a sub directory is in my htdocs folder, but I want to password protect it

so when they get the link they will enter a username and password that I will have given them.

so far I have put this in the htpasswd file

htpasswd

Username:Password

AuthUserFile /htdocs/dir/the name of the file/.htpasswd
AuthGroupFile /dev/null
AuthName "Enter the Password"
AuthType Basic

require user username



Please note I have omitted the username and password and yes the password was in code...I used the link to generate it...I hope that was correct?
When I uploaded an .htaccess file all it had in it was htaccess, i am not sure what I have to put in that, the tutorial was not very clear about the two together.

I am sorry for my ignorance...but I am willing to learn.

Thanks again for all your help
Julie
csogilvie
Grafter
Posts: 5,852
Registered: 04-04-2007

htpassword

Your .htpasswd should look like:

username:encryptedpass


Your .htaccess should look like:

AuthUserFile /share/isp/plusnet/www/ju/julesj/htdocs/path/.htpasswd
AuthGroupFile /dev/null
AuthName "Enter the Password"
AuthType Basic

require user username

You should replace path with the path to the folder you are protecting. The .htaccess should be uploaded into the folder you are protecting, along with the .htpasswd file.

If you were protecting www.julesj.plus.com/secret/folder/ then you would replace "path" with "secret/folder"

Hope this helps...
Community Veteran
Posts: 14,469
Registered: 30-07-2007

htpassword

OK, a few things wrong there:

You need 2 files, one called .htaccess and one called .htpasswd (both need the leading dot (.) in the filename)

In .htpasswd you just need:

username:password (i.e your actual ones you have not specified)

in the .htaccess file you need:

AuthUserFile /share/isp/plusnet/www/ju/julesj//htdocs/dir/the name of the file/.htpasswd
AuthGroupFile /dev/null
AuthName "Enter the Password"
AuthType Basic

require user username


Note: you cannot just protect a single file. The password protection applies to a directory and all the files within it so dir/the name of the file must be a directory not the actual file you want to protect. The file you want to protect then needs to be stored in the directory. So if your zip file is in a directory called dir then the AuthUserFile should be /share/isp/plusnet/www/ju/julesj//htdocs/dir/.htpasswd and the .htaccess and .htpasswd files then need to go in directory dir to protect it.

Do you understand?
Julie
Grafter
Posts: 791
Registered: 28-07-2007

htpassword

Hi

Yes thanks very much I have now done what you told me, I really appreciate all your help, and it is making sense now, sorry for being such a pain :roll:

I now have the login box the username is there but the password does not work?
Do you know why this is...I have also tried generating it again but still no luck

thanks again
Julie
Community Veteran
Posts: 14,469
Registered: 30-07-2007

htpassword

The password is case sensitive so are you sure you are entering it exactly as you encrypted it - i.e. with the same upper and lower characters.

Are you sure you copied the encrypted password exactly as it was encrypted into the .htpasswd file with the necessary upper and lower case characters? Make sure there are no extra spaces between the : and at the end of the line in the .htpasswd file. Also is the login name being entered exactly as specified in the .htpasswd file?

You could try changing the AuthName to something different like 'Password Please' to make sure it is using the correct .htaccess and .htpasswd file.

Do you have any other .htaccess or .htpasswd files in any other directories? If so delete them.
Julie
Grafter
Posts: 791
Registered: 28-07-2007

htpassword

Hi

Yes thanks again for your reply, I have checked the password I copied and pasted it from the encrypted page and double checked there were no mistakes. I also kept everything in lowercase to make sure of no mistakes.

The .htpasswd file just has the username and password in...I take it that is correct from your previous post?

this is the error I am getting after having to type in the password 3 times
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.

Does the .htpasswd have to be chmod at all? I am clutching at straws here
Wink

I would like to thank you again for your time Cheesy
csogilvie
Grafter
Posts: 5,852
Registered: 04-04-2007

htpassword

Yep, just the username and password seperated by a colon with no space.

Presumably by "I also kept everything in lowercase to make sure of no mistakes" you mean BEFORE you encryped the password, as the encrypted password may have capitals in it even if the original one only has lowercase.

You shouldn't need to chmod the .htaccess and .htpasswd files.
Julie
Grafter
Posts: 791
Registered: 28-07-2007

htpassword

Hi

Yes I meant before I encrypted the password...
I have tried a new password...double cheked it again and its still doing it...

This is really driving me nuts... :x

I don't know what to try next..
Julie