Can I use htpasswd to password protect a directory?

Asked by: / 5 Points
2011-10-04 6:59 pm EST
How To
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?


-- 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


13,688 Points
2011-10-04 8:08 pm 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 "\.(css|gif|png|js)$">
Order allow,deny
Allow from all
Satisfy any

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

2014-06-17 10:29 pm 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.
2,342 Points
2014-06-18 8:48 am 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!

Help Center Search

Current Customers

Email: Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
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.