You need to turn off Multiviews:
Options -Multiviews
Multiviews is a mod_negotiation option that tells it to try to match a request to physical files. When it sees a request like /api/somtehin
and then sees that there's a file named api.php
, it will map to that file right away, completely bypassing mod_rewrite.