[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Password protect a web page

Is there a way to password protect a file on a web page? I have a site I'm working on and the client would like to have a link to an internal directory; however, they would like it to be password protected (the link is within a page with other information) Please let me know if there is a way to do this.

I'm working on the site on a macbook pro using adobe GoLive

  • 4
1 Solution
How do I secure a Page?
Let's say you want to restrict access to the directory called "/home/me/public_html/secret/" to just a small group of people. Then you need to create two files:

    * /home/me/public_html/secret/.htaccess - which details the access restrictions for that directory
    * .htpasswd - has the username and password details. It doesn't need to be in the same directory

Here's a sample .htaccess file:

AuthUserFile /home/me/public_html/.htpasswd
AuthName "Access to Private Web Pages"
AuthType Basic

require valid-user

Note that the .htaccess file needs to be readable by the webserver for it to work. You should set its permissions to 644 (ie. chmod 644 .htaccess).

You need to create the .htpasswd file, which just contains a username and crypt'd password separated by a ':' on each line, eg:


This can be created on any CSE linux machine, like this:

htpasswd -c /home/me/public_html/.htpasswd  me

Which will then prompt you for the password for "me" and add the entry to the .htpasswd file. Run "man htpasswd" for more details.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now