Since you tagged this with PHP, I'll add a little perspective from what I did, and it may or may not help you.
You can, of course, write solely in .htaccess, being careful about order. For instance, let's say that you have:
RewriteRule ^user/([0-9]+)/update$ ./index.php?user=$1&action=update
RewriteRule ^user/([0-9]+)$ ./index.php?user=$1
Then it should, upon receiving
http://localhost/user/1/update
go to
http://localhost/index.php?user=$1&action=update
and not
http://localhost/index.php?user=$1
Now, what I did instead was push everything to index.php?q=$1
RewriteRule ^(.*)$ index.php?q=$1
Then I used index.php to handle how the query was broken up. So let's say someone enters
http://www.example.com/user/18239810/update
this would go to
http://www.example.com/index.php?q=user/18239810/update
From there, explode the query string along the first /
to give user
and 18239810/update
.
This would tell me that I need to pass 18239810/update
to the user
controller. In that controller, I again explode the argument into the user id and command, and I can switch on the command to tell how to load the page, passing the user id as an argument to the update
function.
Very quick and dirty example (index.php):
<?php
$getString = explode('/', $_GET['q'], 1);
$controller = $getString[0].'Controller';
require_once('/controllers/'.$controller.'.php');
$loadedController = new $controller( $getString[1] );
?>
Of course, this means that constructors all must take a string argument that will be parsed for acceptable values. You can do this with explodes and switch statements, always defaulting back to the standard front page to prevent unauthorized access based on random guessing.
/user/1
,/user/BigChris
,/user/BigChris1
? – Moriarty