views:

158

answers:

3

when I use .htaccess file inside a folder named admin with the following code

AuthName "Alertme"
AuthType Basic
AuthUserFile /mobs/.htpasswd
require valid-user

and .htpasswd file with following code

rajasekar:66Acdia7gE1to

While accessing the file inside folder, it gives server error, The server encountered an internal error and was unable to complete your request

why is this happening. help me

A: 

Make sure that /mobs/.htpasswd is absolute (not relative to your webroot) path on your filesystem

igorp1024
A: 

This usually happens when your htaccess and/or htpasswd file can't be read by apache. Either because the user apache is running under doesn't have the needed rights on these files.

Nicolas
+1  A: 

Most likely your Apache config does now allow Auth* directives in .htaccess in that directory and/or location. You can check for sure why looking in the error_log for that host. There'll be a line that looks like:

[Wed Dec 02 22:13:14 2009] [alert] [client x.x.x.x] /path/leading/to/.htaccess: AuthName not allowed here

This error will show up as a "500 Internal Server" error for any client attempting to access that particular server/directory.

You will need to add an "AllowOverride AuthConfig" so Apache will accept the Auth directives in the .htaccess. Details are here in the Apache docs.

Marc B
Agreed. With Apache errors, it's always best to check your log file to see what Apache says is going wrong.
S Pangborn