How are rewrite rules applied in WordPress?

index.php acts as a router. All requests are sent through index.php which looks up the rules in the database and directs you to the correct location. This should give you an idea of how a PHP router works. The .htaccess just removes index.php from the URL. More rules can be created using the WP_Rewrite class.