Testadmin
Testadmin

Reputation: 2898

protecting my web page and folder from external using .htaccess and .htpassword in php

Hai

I want to protect a folder (protect) and the files inside that folder. I have created a .htaccess file and put the following code.

AuthName "Myfolder" AuthType Basic AuthUserFile url/protect/.htpasswd Require valid-user

Also created a .htpassword file which contain username:password

When I run my URL http://localhost/url/protect, I got a pop up asking username and password, I entered username as username and password as password. After that I got an error page "server error 500" "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster."

Why this happened?. Any thing wrong here? Anything needs to see my pages under the folder. Please give me the answer.

Upvotes: 0

Views: 498

Answers (2)

Kerry Jones
Kerry Jones

Reputation: 21848

What Col. Shrapnel said on the absolute path, here is a tutorial:

http://webdevelopment.kerryjones.net/security/htaccess-securing-a-folder/

Upvotes: 0

Your Common Sense
Your Common Sense

Reputation: 157882

.htpassword file must be created using htpasswd utility

also, AuthUserFile file path must be absolute.

And, aside from my guessing you should see the actual error explanation in the error_log file

Upvotes: 1

Related Questions