htaccess problem

Joined
12 Feb 2006
Posts
17,674
Location
Surrey
i'm trying to protect a directory by adding htaccess username and password verification.

i uploaded and it asked for username/password so thought i'd test by trying wrong details. i then got a 500 internal error and that's all i get now which is a pain as i'd like to try again.

any thing i'm doing wrong?

this is what i have...

.htaccess file

Code:
AuthType Basic
AuthName "This is a protected area"
AuthUserFile /home/xyz/public_html/php/upload
Require valid-user

.htpasswd file
Code:
admin:OdfRyggFdf2Z/gI
 
error log.

[Thu Sep 02 20:34:13 2010] [error] [client 86.16.135.182] File does not exist: /home/xyz/public_html/500.shtml
[Thu Sep 02 20:34:13 2010] [error] [client 86.16.135.182] (9)Bad file descriptor: Could not open password file: /home/xyz/public_html/php/upload
[Thu Sep 02 20:34:13 2010] [error] Access to file /home/xyz/public_html/php/upload denied by server: not a regular file

htpasswd generator is what i used :p
 
The AuthUserFile should point to the path of the .htpasswd file, so if you placed it in public_html/php/upload you would use:

PHP:
AuthType Basic
AuthName "This is a protected area"
AuthUserFile /home/xyz/public_html/php/upload/.htpasswd
Require valid-user

Are you changing /home/xyz to the actual path of your account on the server?

the only part i'm changing is the xyz part, /home is there as it should be, or am i wrong?

what weird is whilst the htaccess file is there when i'm in folder php i can't see php folder, although i can access it by manually adding it to the url, but then when i remove the htaccess file i can now find the folder again and view it fine. if i then re-add the htaccess file and refresh i can continue accessing the folder and viewing it from php with no attempt of logging
 
Last edited:
maybe it's letting me in now for some reason not sure but i think adding .htpasswd has helped.

i don't get asked anything now, though i did once today about 3 hours ago and i entered the correct info but it then showed same error after, but in the latest error logs there is

[Thu Sep 02 23:50:48 2010] [error] [client 86.16.135.182] client denied by server configuration: /home/xyz/public_html/php/upload/.htpasswd, referer: http://www.mysite.co.uk/php/
[Thu Sep 02 23:50:48 2010] [error] [client 86.16.135.182] client denied by server configuration: /home/xyz/public_html/php/upload/.htaccess, referer: http://www.mysite.co.uk/php/
 
hmm maybe it's working now but i am let in every time i try to access it but then as i said i did try putting in correct details yesterday when it finally did ask me to login. i think adding the .htpasswd as you suggested perhaps did it.
 
Back
Top Bottom