Password Protecting A Blog
Filed under Blogging
I did some digging over the past week to figure out how to password protect a section of my blog.
My blog is hosted with an Apache server.
I read this article about how Apache supports access control of files on a server.
There are two parts:
- An .htaccess file that contains all the settings for access control. This file also points to a password file.
- A password file
The .htaccess file impacts everything at the same level as .htaccess and below. The documentation page for .htaccess is here.
A sample .htaccess file looks like this:
AuthType Basic
AuthName "Password Required"
AuthUserFile /www/passwords/password.file
AuthGroupFile /www/passwords/group.file
Require Group admins
I found that I had to start .htaccess with "<Files DIRNAME>" and end with "</Files>" in order to make it work for me...not sure why. I only learned about this after I called my hosting company (1&1) for help. It may be particular 1&1.
Then I had to create a password file (password.file in the above example).
This page explains how to set up a password file with the command "htpasswd."
I used PuTTY to login to the server and vi to edit the .htaccess file.