There is little work with apache's .htaccess - most of the logic is in the php itself. Apache just redirects every request to an chosen script file.
I assume you use apache wid mod_rewrite. If that's the case you should add this to .htaccess file:
# check if mod_rewrite is present
<IfModule mod_rewrite.c>
#turns it on
RewriteEngine on
#if the requested url isn't a file or a dir
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#process index.php, no matter what was in the url
RewriteRule ^ index.php [L]
</IfModule>
(note that .htaccess must also have permissions to overwrite the apache's current settings)
in the index.php you can check what url was sequested and process the info
$whatTheUserRequested=$_SERVER['REQUEST_URI'];
$parameterArray=explode('/', $whatTheUserRequested);
//check the first param.
switch($parameterArray[1])
{
//if it was something like "thesite.com/main/fsadf/hgfdsgsdf/...."
case "main":
include "mainPage.php";
//....or do something else
break;
//if it was something like "thesite.com/login/asdfe/xxxx/...."
case "login":
include "loginPage.php";
//....or do something else
break;
default:
//here you MUST check if $parameterArray[1] is a username
if(check in db if $parameterArray[1] is user)
{
include "userPage.php";
}
else
{
include "pageNotFound.html"
};
}
You may check also for the 3rd or 4th parameter in the included php's, to process url's like "mysite.com/johnny95/edit"