My suggestion would be to use a very simple rewrite to a front controller (like index.php) and then use code in that file to evaluate the requested route.
RewriteRule ^index\.php$ index.php [L,QSA]
In your api example you would then have paremeters q,page,count available in $_GET
due to the QSA (query string append) flag on the rewrite rule.
This leaves it up to you to interpret the rest of the URI.
You can do that rather simply using simple string manipulation techniques.
// discard query string after trimming leftmost '/' from URI
$uri_parts = explode('?', ltrim($_SERVER['REQUEST_URI'], '/'));
$uri_base = $uri_parts[0];
// get routing information from URI
$route_parts = explode('/', $uri_base);
$api_version = $route_parts[0];
$controller = $route_parts[1];
$action_parts = explode('.',$route_parts[2]);
$action = $action_parts[0];
$format = $action_parts[1];
// your parameters would be in $_GET['q'], $_GET['page'], etc.
You might consider Googling PHP URL routing
to get more examples of how to set up a proper router, as this was just a very basic example and does not include any sort of validation or handling of more complex routes.
The benefit of this approach is that it keeps your routing logic all in PHP rather than split between Apache server config and PHP. If you need to make routing changes, you do it in PHP only. This also prevents mixing of routing information with actual parameter information within $_GET
as would happen with your proposed rewrite.