How To Set Up a Password for a Website

When you are creating a website, you might decide you need to have some sections that are not exposed to the public. These pages can also be hidden from search engines so the only people or computers that are allowed to view the pages are those who have been provided with the password you have created. The simplest and easiest way to create a password-protected section of your website is to use the htaccess file.

Instructions

    • 1

      Decide which directory of your website you want protected by the password. This method will protect all files in that one directory. If you want your entire website to be password protected, you will complete the following steps in the root directory of your website.

    • 2

      Create a new, plain text file named .htaccess. Note the file name must begin with the period and be spelled exactly as it is. You can create this file using any standard text editor.

    • 3

      Add the following four lines in your .htaccess file:
      AuthUserFile /full/path/to/your/directory/.htpassword
      AuthName "Title to appear on password request window"
      AuthType Basic
      Require valid-user
      Save this file in the Web directory you selected in Step 1.

    • 4

      Create the .htpassword file you just referenced in Step 3. This will need to be done on the Web server using the following command (via telnet or another method at a command prompt):
      htpasswd -c .htpasswd nameOfPerson
      This will allow you to create a password for the person you listed on that line for "nameOfPerson." The system will prompt you for the password for the person named. You can set up one name and password combination or you can set up a number of them.

    • 5

      Ensure the .htaccess file and the .htpassword file have read-only permission for everyone. This can be done by right-clicking on the files in some operating systems and selecting "Properties." In other operating systems, you can use the chmod command (chmod a+r .htaccess).

Related Searches:

Comments

You May Also Like

Related Ads

Featured