I have thought about using WordPress – or maybe just copy a few functions to an internal site – but before I'd use it I would like to know how it's working.
How is the .htaccess and URL rewrite combined with index.php?
There is a very detailed summary in the WordPress Codex on Using Permalinks.
If you are interested in how it was implemented, see the WordPress Rewrite API in file /wordpress/wp-includes/rewrite.php
and check the related reference entry in WP Codex.