How Do I Password Protect A Single File On My Website



How Do I Password Protect A Single File On My Website

How Do I Password Protect A Single File On My Website

Most webhosting providers provide tools (a control panel) that enables you to quickly and easily password protect your entire website or any folder in the public directory.  Password protecting a single file isn't difficult, but requires a bit of experience.

Requirements:
  • htaccess.  It must be provisioned on your Web server.  Htaccess is nearly universally supportted. If you don't know if your server supports htaccess, you should contact your hosting provider.

  • A plain text editor (like notepad). Use only a simple text editor.  Do not us MS Word or any other word processing program, since they will embed alien markup.

  • FTP access or control panel access to your website.  I recommend using FileZilla as a FTP client. 
Note:

Maintain the security of keep your passwords!  Be dead sure that the user file is not be accessible via a Web browser, put in a folder in the root directory, level with or above the public_html or www folder on your website.

I reccomend using a program like KeePass to generate and store encrypted passwords.  (This is a locally run program - not a remotely run script).

Steps:
  1. Create a new text file called .htpasswd.  The period at the beginning of the filename is required.

  2. Create the passwords for your users and paste them into your .htpasswd file, using one line for every username that requires a password.  Save the file.

  3. Upload the .htpasswd file to a directory on your Web server that is on the same level or above the public_html folder or the www folder.

  4. Create a new file called .htaccess.

  5. Your .htaccess file must include the following:
    AuthUserFile /folder/folder/htpasswd/file/.htpasswd
    AuthName "pagename.php"
    AuthType Basic
    <Files "pagename.php">
    require valid-user
    </Files>

      
  6. Change "/folder/folder/htpasswd/file/.htpasswd" to the full path to the .htpasswd file you uploaded in the 3rd step.

  7. Change "pagename.php" to the actual name of the page/file being protected.

  8. Change "pagename.php"to the filename of the page that you want to protect.

  9. Save the file.

  10. Upload it to the directory of the file you are protecting.

  11. Now test.  Go the url of the file you are protecting.  It should prompt for a username and password.  If the username and password you are testing does not work, check them again to make sure you are entering properly.  Usernames and passwords are both case sensitive. 

    If you still have trouble, you will need to contact your webhosting systems administrator.




Powered by http://www.a1smallbusinessmarketing.com.

Website Design   SEO   Call Center

Make a Website, Website Software Licensee #1209

This HTML Document Passes HTML Validation