VDS Sphera Knowledge Base

Main / Browse Categories / Apache / How do I password protect my site?

Print article Print Article    Email article Email Article

How do I password protect my site?
You have two choices.

1.) Install the "Web Passwords" ValueApp in your control panel. Web Passwords is a point-and-click utility for password protection of a directory, which allows you to force visitors of your site to enter a username and password, before being able to view that directory of your site.

2.) Add two files to your existing web site: .htpasswd and .htaccess

The .htpasswd file is a list of usernames and passwords to give access to your private folders. You can add and delete any number of people to this list (just add/delete entries to/from the .htpasswd file). The .htaccess file is the file that tells the server which directories are password protected. The .htaccess file will not allow anyone on the web to view the page unless they enter a valid username and password.

Creating the .htpasswd file
The .htpasswd file looks something like this:

myname:CFprq2X6tlOGW 
hisname:g4PoEl8SLw5jb
To create this file, go to the directory that you would like to password-protect and type the command:
htpasswd -bc .htpasswd username password
'htpasswd' is the program, '.htpasswd' is the file that will be created, '-b' allows the password after the username, 'c' is to create the new file, 'username' is the username of your choice, and 'password' is password of your choice.

Creating the .htaccess file
Create a file in the same directory, named .htaccess, with the following text:

AuthType Basic 
AuthUserFile /path/to/the/.htpasswd 
AuthName "Protected Area" 
require valid-user 
In the AuthName line, you can replace the text with whatever you wish (though you must surround it with quotes). Be sure to replace /path/to/the with the correct path to the directory where the .htpasswd file is located.

User Comments
How do I password protect my site?  
There are no user comments for this topic.
 

Attachments
No attachments.

Related Articles
 Where is the Apache httpd.conf file located?
 How do I restart Apache?
 How can I create a Script Alias in Apache to Neomail?
 How can I prevent Directory Listing?
 How do I prevent hot linking of my pictures, movies, or other files?

Why Choose Our Hosting?

  • Unmatched Customer Support!
  • Virtual Private Server technology provides a rich, dedicated-like environment for every account.
  • We are known for our superb quality, performance and flexible hosting environment. We manage the server, software, and network you do the rest.
Continue reading »

Featured Hosting Plan


Learn more about our VPS Extreme

What is Included?

  • PHP 5/MySQL 5
  • Parallels® Plesk Panel 10
  • Unique IP Address
  • Daily VPS Backups (Off Server)
  • SAS Hardware Raid diskspace
  • CentOS 5 x86_64 bit
  • Multi-homed Tier 1 Bandwidth
  • Full Upgrade capabilities
Continue reading »