If you have $50 and are willing to spend it, you could go to get .htaccess manager from htaccess.biz and use it. I recently bought it for a client and it works for what they want (to secure one folder which has documents to be downloaded).
In PHP you'd have to use some sort of backend component to handle authorizations. Whether you store usernames and passwords in a database, or in a text-file or even an xml file you need a way of keeping the data stored.
There are plenty of tutorials around for basic login scripts. I guess at the most basic level it's nothing more than:
<?php
if(isset($_POST))
{
$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database');
$query = sprintf("SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
mysql_real_escape_string($_POST['username']),
md5($_POST['password']));
$result = mysql_query($query) or die('Unable to process login at this time.');
if(mysql_num_rows($result) == 1)
{
session_start();
$_SESSION['user'] = mysql_fetch_assoc($result);
$_SESSION['auth'] = true;
header('Location: index2.php');
}
}
?><html>
<head>
<title>Member's Only Area</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="user">Username:</label>
<input id="user" name="username" type="text" /><br />
<label for="pass">Password:</label>
<input id="pass" name="password" type="password" /><br />
<input name="submit" type="submit" value="Login" />
</form>
</body>
</html>
If you have a mysql table called "users" you can use that. Or you can adapt that to your needs. But that's a very very basic example.