Use the "setting up password protection" tip to set up a password protected directory. Let's call that directory members. Under that members directory have a subdirectory for each member. For example members/joe and members/jane.
Then in that password protected directory members, use the "Passing user authentication information to PHP" to identify the user and route them to the directory with their name. So you have a page members/index.php which would contain a script something like this:
Code: Select all
<?php
$directory = $_SERVER['REMOTE_USER']; // directory name is the user name
if (file_exists($directory)) {
header('Location: '.$directory.'/'); // go to the user directory
} else {
header('Location: http://yourdomain/error.htm'); // not found
}
?>
Code: Select all
RewriteEngine On
RewriteCond %{REMOTE_USER} !^joe
RewriteRule . http://yourdomain.com/error.htm [L]
In summary:
- A member always goes to page domain.com/members. If the member is not logged in they will get the login prompt and then be sent to their page. If the member has already logged in, they will just be sent to their page.
- Using this method you must put each member name in the htpasswd file for authentication, use that name as a directory name, and put that name in the htaccess file for that directory. So it is not maintenance free - but it is very secure, easy and "light weight". Note that all this is case sensitive, Joe is not the same as joe. The .htpasswd member name must match the dirctory name which must match the name used in the .htaccess for that directory.