Can I use htpasswd to password protect a directory?

Asked by:
sidd@patwardhans.net / 5 Points
Time:
2011-10-05 1:59 am EST
Category:
How To
Hits:
1,371
I need to password protect a directory on my website, and I was trying to use .htpasswd to achieve this. I keep getting an "Internal Server Error" if I try to access that URL from a browser. The server logs don't seem to have a meaningful message (except that 501.shtml and 400.shtml files are not found). Is there anything else that I need to do get this set up? Is there any way to find out what may be causing the internal server error?

Thanks.

-- Sid.

To ask this user for more information, please first login.

To submit an answer, please login.

Best answer chosen by Web Hosting Hub staff

0

ChristiNi
Staff
13,688 Points
2011-10-05 3:08 am EST
Hello Sid,

I'm sorry you're having trouble password protecting your directory. I'm happy to help you with that. cPanel offers the option to password protect a directory and will write to the .htaccess file in order to accomplish that. For step-by-step instructions, please see How to Password Protect a Directory

Please let us know if you have any questions or need further assistance, we're always happy to help.

Thank you,

Christi N

To submit a comment on this answer, please first login.

Hello, i have a vps (centos) and .htpasswd working as expected but not in webhostinghub. I want to protect my wp-admin folder and this is the .htaccess file:

AuthType Basic
AuthName "Please enter your username and password:"
AuthUserFile path/to/.htpasswd/file
Require valid-user
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
<Files "\.(css|gif|png|js)$">
Order allow,deny
Allow from all
Satisfy any
</Files>

it's keep returning 404 when i go to http://wpsite.tld/admin
thanks..
bago269
3 Points

2014-06-18 5:29 am EST
These lines would not affect the location of your WordPress admin at all. You wrote that you were going to http://wpsite.tld/admin when it should be http://wpsite.tld/wp-admin.
JeffMa
2,342 Points
Staff
2014-06-18 3:48 pm EST
Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 757-416-6627 Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}