RewriteEngine On

# If the request is for a file that exists, serve it
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Otherwise, route to api.php
RewriteRule ^(.*)$ api.php [QSA,L]