headerIMG

B2B Articles - June 06, 2010

Use .htaccess and .htpasswd To Protect A Website Or Directory

There is a very simple and quick way to protect a website or web directory using .htaccess and .htpasswrd. This can be a very efficient way for web designers to protect web pages or sites in progress. The effect will be that any user trying to access the protected directory will be prompted by a password request.

First start with .htaccess:
You will need to define the exact path to your document on the web server. If you are running PHP, you can run the phpinfo(); on a web page to locate the true path to that document or directory. You will actually mark a path to the .htpasswrd file.

/home/domains/example.com/html/directory/.htpasswd

.htaccess instructions:

AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/the/directory/you/are/protecting/.htpasswd
require valid-user

.htpsswrd username and password

username:password

You can use encryption for the .htpasswrd for added security. There are a number of tools out there for simple password encryption. Two options are listed below, but there are a number out there for encrypting htpasswrd. You could try a simple Google search for "htpasswrd encryption" to find more options.

Two free htpasswrd encryption options:

  • https://davidwalsh.name/web-development-tools
  • https://sherylcanter.com/encrypt.php

Tel 212-993-7809  

Ironpaper ®
10 East 33rd Street 
6th Floor
New York, NY 10016
Map

Ironpaper - B2B Agency

B2B Marketing and Growth Agency.

Grow your B2B business boldly. Ironpaper is a B2B marketing agency. We build growth engines for marketing and sales success. We drive demand generation campaigns, ABM programs, B2B content, sales enablement, qualified leads, and B2B marketing efforts. 

Ironpaper Twitter Ironpaper Linkedin