How do I Build a Website for Limited Access?by C. Taylor
When you want to limit access to a website, you need to password protect it and only grant passwords to those who wish to access to site. There are many ways to do this, but using .htaccess/.htpasswd is the simplest and most universally use-able solution. In addition, .htaccess makes maintaining usernames and passwords relatively painless. To implement this password protection, you only need access to the root folder you wish to protect.
Log into your server or web host and navigate to the folder you wish to protect. This can be a subfolder or the main "root" folder of the entire site.
Create two text files and name them ".htaccess" and ".htpasswd" within the folder you wish to protect.
If you are using a Windows server, you may encounter an error, stating you have to provide a name for those files. You can work around this by creating the files "name.htaccess" and "name.htpasswd" on the server, and then renaming the files using your FTP software. This can usually be done by logging into the server, navigating to the folder, right-clicking the files and select "rename."
Open ".htaccess" in Notepad or a simple text editor. Type the following text into the file, save and close it. Some servers may require an absolute path to ".htpasswd", such that ".htpasswd" needs to be "C:\www\USER.htpassword" or whatever the actual path is:
Decide the username(s) and password(s) you wish to create and enter them into an online encrypter for the actual text (see Resources). Some systems will allow this encryption via a command prompt, but others will not; at this point, it would be easier to just follow this method. Copy the resulting output, which will look something like:
Open ".htpasswd" in a text editor and copy just that username/password combination in the file, save and close it. In the example above, "test:EhwqGa.xGAuvk" is actually the username "text" and the password "testing," so you would still login using those words.
Browse to your protected folder using an Internet browser and test by entering your username and password. Your website can then be a completely designed HTML or dynamic coding website, or simply a place to upload files available for download to selected users.
- photo_camera password errata image by UBE from Fotolia.com